Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src use readlink with bufsize - 1; approved thorpej.



details:   https://anonhg.NetBSD.org/src/rev/f32bfd46a4af
branches:  trunk
changeset: 538416:f32bfd46a4af
user:      provos <provos%NetBSD.org@localhost>
date:      Sat Oct 19 20:33:17 2002 +0000

description:
use readlink with bufsize - 1; approved thorpej.

diffstat:

 bin/cp/utils.c                         |  6 +++---
 bin/csh/dir.c                          |  8 ++++----
 bin/pax/ftree.c                        |  6 +++---
 crypto/dist/heimdal/appl/ftp/ftpd/ls.c |  4 ++--
 crypto/dist/krb4/appl/ftp/ftpd/ls.c    |  4 ++--
 distrib/utils/sysinst/target.c         |  6 +++---
 distrib/utils/sysinst/util.c           |  4 ++--
 usr.bin/find/ls.c                      |  6 +++---
 usr.bin/stat/stat.c                    |  6 +++---
 usr.sbin/catman/catman.c               |  4 ++--
 usr.sbin/makefs/walk.c                 |  6 +++---
 usr.sbin/pkg_install/create/pl.c       |  6 +++---
 usr.sbin/sup/source/supcmeat.c         |  7 +++++--
 usr.sbin/sup/source/supfilesrv.c       |  4 ++--
 14 files changed, 40 insertions(+), 37 deletions(-)

diffs (truncated from 344 to 300 lines):

diff -r 26d90f9ebfeb -r f32bfd46a4af bin/cp/utils.c
--- a/bin/cp/utils.c    Sat Oct 19 20:32:48 2002 +0000
+++ b/bin/cp/utils.c    Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.20 2001/09/13 09:53:59 wiz Exp $ */
+/* $NetBSD: utils.c,v 1.21 2002/10/19 20:33:17 provos Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)utils.c    8.3 (Berkeley) 4/1/94";
 #else
-__RCSID("$NetBSD: utils.c,v 1.20 2001/09/13 09:53:59 wiz Exp $");
+__RCSID("$NetBSD: utils.c,v 1.21 2002/10/19 20:33:17 provos Exp $");
 #endif
 #endif /* not lint */
 
@@ -221,7 +221,7 @@
        int len;
        char target[MAXPATHLEN];
 
-       if ((len = readlink(p->fts_path, target, sizeof(target))) == -1) {
+       if ((len = readlink(p->fts_path, target, sizeof(target)-1)) == -1) {
                warn("readlink: %s", p->fts_path);
                return (1);
        }
diff -r 26d90f9ebfeb -r f32bfd46a4af bin/csh/dir.c
--- a/bin/csh/dir.c     Sat Oct 19 20:32:48 2002 +0000
+++ b/bin/csh/dir.c     Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.20 2002/08/12 02:37:26 itojun Exp $ */
+/* $NetBSD: dir.c,v 1.21 2002/10/19 20:33:17 provos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c      8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dir.c,v 1.20 2002/08/12 02:37:26 itojun Exp $");
+__RCSID("$NetBSD: dir.c,v 1.21 2002/10/19 20:33:17 provos Exp $");
 #endif
 #endif /* not lint */
 
@@ -679,7 +679,7 @@
            *--sp = 0;          /* form the pathname for readlink */
            if (sp != cp && !adrof(STRignore_symlinks) &&
                (cc = readlink(short2str(cp), tlink,
-                              sizeof tlink)) >= 0) {
+                              sizeof(tlink) - 1)) >= 0) {
                (void)Strcpy(slink, str2short(tlink));
                slink[cc] = '\0';
 
@@ -762,7 +762,7 @@
 
            if (sp != cp && adrof(STRchase_symlinks) &&
                !adrof(STRignore_symlinks) &&
-               (cc = readlink(short2str(cp), tlink, sizeof(tlink))) >= 0) {
+               (cc = readlink(short2str(cp), tlink, sizeof(tlink)-1)) >= 0) {
                (void)Strcpy(slink, str2short(tlink));
                slink[cc] = '\0';
 
diff -r 26d90f9ebfeb -r f32bfd46a4af bin/pax/ftree.c
--- a/bin/pax/ftree.c   Sat Oct 19 20:32:48 2002 +0000
+++ b/bin/pax/ftree.c   Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftree.c,v 1.22 2002/10/12 15:39:29 christos Exp $      */
+/*     $NetBSD: ftree.c,v 1.23 2002/10/19 20:33:18 provos Exp $        */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -78,7 +78,7 @@
 #if 0
 static char sccsid[] = "@(#)ftree.c    8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ftree.c,v 1.22 2002/10/12 15:39:29 christos Exp $");
+__RCSID("$NetBSD: ftree.c,v 1.23 2002/10/19 20:33:18 provos Exp $");
 #endif
 #endif /* not lint */
 
@@ -712,7 +712,7 @@
                         */
                        } else if ((cnt =
                            readlink(ftent->fts_path, arcn->ln_name,
-                           PAXPATHLEN)) < 0) {
+                           PAXPATHLEN-1)) < 0) {
                                syswarn(1, errno, "Unable to read symlink %s",
                                    ftent->fts_path);
                                continue;
diff -r 26d90f9ebfeb -r f32bfd46a4af crypto/dist/heimdal/appl/ftp/ftpd/ls.c
--- a/crypto/dist/heimdal/appl/ftp/ftpd/ls.c    Sat Oct 19 20:32:48 2002 +0000
+++ b/crypto/dist/heimdal/appl/ftp/ftpd/ls.c    Sat Oct 19 20:33:17 2002 +0000
@@ -34,7 +34,7 @@
 #include "ftpd_locl.h"
 
 __RCSID("$Heimdal: ls.c,v 1.25 2002/08/22 08:31:03 joda Exp $"
-        "$NetBSD: ls.c,v 1.1.1.5 2002/09/12 12:41:35 joda Exp $");
+        "$NetBSD: ls.c,v 1.2 2002/10/19 20:33:18 provos Exp $");
 
 #else
 #include <stdio.h>
@@ -269,7 +269,7 @@
     }
     if(S_ISLNK(st->st_mode)) {
        int n;
-       n = readlink((char *)filename, buf, sizeof(buf));
+       n = readlink((char *)filename, buf, sizeof(buf)-1);
        if(n >= 0) {
            buf[n] = '\0';
            file->link = strdup(buf);
diff -r 26d90f9ebfeb -r f32bfd46a4af crypto/dist/krb4/appl/ftp/ftpd/ls.c
--- a/crypto/dist/krb4/appl/ftp/ftpd/ls.c       Sat Oct 19 20:32:48 2002 +0000
+++ b/crypto/dist/krb4/appl/ftp/ftpd/ls.c       Sat Oct 19 20:33:17 2002 +0000
@@ -34,7 +34,7 @@
 #include "ftpd_locl.h"
 
 __RCSID("$KTH-KRB: ls.c,v 1.25 2002/08/22 08:31:03 joda Exp $"
-      "$NetBSD: ls.c,v 1.1.1.4 2002/09/12 12:22:08 joda Exp $");
+      "$NetBSD: ls.c,v 1.2 2002/10/19 20:33:18 provos Exp $");
 
 #else
 #include <stdio.h>
@@ -269,7 +269,7 @@
     }
     if(S_ISLNK(st->st_mode)) {
        int n;
-       n = readlink((char *)filename, buf, sizeof(buf));
+       n = readlink((char *)filename, buf, sizeof(buf)-1);
        if(n >= 0) {
            buf[n] = '\0';
            file->link = strdup(buf);
diff -r 26d90f9ebfeb -r f32bfd46a4af distrib/utils/sysinst/target.c
--- a/distrib/utils/sysinst/target.c    Sat Oct 19 20:32:48 2002 +0000
+++ b/distrib/utils/sysinst/target.c    Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: target.c,v 1.31 2001/01/14 02:38:15 mrg Exp $  */
+/*     $NetBSD: target.c,v 1.32 2002/10/19 20:33:18 provos Exp $       */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -75,7 +75,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.31 2001/01/14 02:38:15 mrg Exp $");
+__RCSID("$NetBSD: target.c,v 1.32 2002/10/19 20:33:18 provos Exp $");
 #endif
 
 /*
@@ -866,7 +866,7 @@
                                errno = ELOOP;
                                goto err1;
                        }
-                       n = readlink(p, wbuf, MAXPATHLEN);
+                       n = readlink(p, wbuf, MAXPATHLEN - 1);
                        if (n < 0)
                                goto err1;
                        wbuf[n] = '\0';
diff -r 26d90f9ebfeb -r f32bfd46a4af distrib/utils/sysinst/util.c
--- a/distrib/utils/sysinst/util.c      Sat Oct 19 20:32:48 2002 +0000
+++ b/distrib/utils/sysinst/util.c      Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.74 2002/10/05 02:41:54 grant Exp $  */
+/*     $NetBSD: util.c,v 1.75 2002/10/19 20:33:19 provos Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -970,7 +970,7 @@
         * something useful */
 
        rc = readlink(localtime_link, localtime_target,
-                     sizeof(localtime_target));
+                     sizeof(localtime_target) - 1);
        if (rc < 0) {
                /* error, default to UTC */
                tz_default = "UTC";
diff -r 26d90f9ebfeb -r f32bfd46a4af usr.bin/find/ls.c
--- a/usr.bin/find/ls.c Sat Oct 19 20:32:48 2002 +0000
+++ b/usr.bin/find/ls.c Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ls.c,v 1.15 2002/08/01 22:41:34 christos Exp $ */
+/*     $NetBSD: ls.c,v 1.16 2002/10/19 20:33:19 provos Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "from: @(#)ls.c 8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: ls.c,v 1.15 2002/08/01 22:41:34 christos Exp $");
+__RCSID("$NetBSD: ls.c,v 1.16 2002/10/19 20:33:19 provos Exp $");
 #endif
 #endif /* not lint */
 
@@ -121,7 +121,7 @@
        int lnklen;
        char path[MAXPATHLEN + 1];
 
-       if ((lnklen = readlink(name, path, MAXPATHLEN)) == -1) {
+       if ((lnklen = readlink(name, path, MAXPATHLEN - 1)) == -1) {
                warn("%s", name);
                return;
        }
diff -r 26d90f9ebfeb -r f32bfd46a4af usr.bin/stat/stat.c
--- a/usr.bin/stat/stat.c       Sat Oct 19 20:32:48 2002 +0000
+++ b/usr.bin/stat/stat.c       Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stat.c,v 1.8 2002/08/13 20:15:06 atatat Exp $ */
+/*     $NetBSD: stat.c,v 1.9 2002/10/19 20:33:19 provos Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: stat.c,v 1.8 2002/08/13 20:15:06 atatat Exp $");
+__RCSID("$NetBSD: stat.c,v 1.9 2002/10/19 20:33:19 provos Exp $");
 #endif
 
 #include <sys/stat.h>
@@ -683,7 +683,7 @@
                data = 0;
                if (S_ISLNK(st->st_mode)) {
                        snprintf(path, sizeof(path), " -> ");
-                       l = readlink(file, path + 4, sizeof(path) - 4);
+                       l = readlink(file, path + 4, sizeof(path) - 4 - 1);
                        if (l == -1) {
                                linkfail = 1;
                                l = 0;
diff -r 26d90f9ebfeb -r f32bfd46a4af usr.sbin/catman/catman.c
--- a/usr.sbin/catman/catman.c  Sat Oct 19 20:32:48 2002 +0000
+++ b/usr.sbin/catman/catman.c  Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: catman.c,v 1.18 2002/09/13 20:40:04 mycroft Exp $       */
+/*      $NetBSD: catman.c,v 1.19 2002/10/19 20:33:19 provos Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -297,7 +297,7 @@
                                        }
                                } else {
                                        len = readlink(manpaths.gl_pathv[i],
-                                                       path, PATH_MAX);
+                                                       path, PATH_MAX - 1);
                                        if (len == -1)
                                                continue;
                                        if (!strcmp(path, manpaths.gl_pathv[j]))
diff -r 26d90f9ebfeb -r f32bfd46a4af usr.sbin/makefs/walk.c
--- a/usr.sbin/makefs/walk.c    Sat Oct 19 20:32:48 2002 +0000
+++ b/usr.sbin/makefs/walk.c    Sat Oct 19 20:33:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: walk.c,v 1.9 2002/02/08 01:17:32 lukem Exp $   */
+/*     $NetBSD: walk.c,v 1.10 2002/10/19 20:33:20 provos Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: walk.c,v 1.9 2002/02/08 01:17:32 lukem Exp $");
+__RCSID("$NetBSD: walk.c,v 1.10 2002/10/19 20:33:20 provos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -172,7 +172,7 @@
                        char    slink[PATH_MAX+1];
                        int     llen;
 
-                       llen = readlink(path, slink, PATH_MAX);
+                       llen = readlink(path, slink, PATH_MAX - 1);
                        if (llen == -1)
                                err(1, "Readlink `%s'", path);
                        slink[llen] = '\0';
diff -r 26d90f9ebfeb -r f32bfd46a4af usr.sbin/pkg_install/create/pl.c
--- a/usr.sbin/pkg_install/create/pl.c  Sat Oct 19 20:32:48 2002 +0000
+++ b/usr.sbin/pkg_install/create/pl.c  Sat Oct 19 20:33:17 2002 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: pl.c,v 1.22 2002/02/18 00:57:54 hubertf Exp $  */
+/*     $NetBSD: pl.c,v 1.23 2002/10/19 20:33:20 provos Exp $   */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: pl.c,v 1.11 1997/10/08 07:46:35 charnier Exp";
 #else
-__RCSID("$NetBSD: pl.c,v 1.22 2002/02/18 00:57:54 hubertf Exp $");
+__RCSID("$NetBSD: pl.c,v 1.23 2002/10/19 20:33:20 provos Exp $");
 #endif
 #endif
 
@@ -47,7 +47,7 @@
        int     cc;
        int     i;
 
-       if ((cc = readlink(name, oldtgt, sizeof(oldtgt))) > 0) {
+       if ((cc = readlink(name, oldtgt, sizeof(oldtgt) - 1)) > 0) {
                oldtgt[cc] = 0;



Home | Main Index | Thread Index | Old Index