Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sup/source PR/50547: David Binderman: fix bad sizeof
details: https://anonhg.NetBSD.org/src/rev/8b4d6397b205
branches: trunk
changeset: 342241:8b4d6397b205
user: christos <christos%NetBSD.org@localhost>
date: Sun Dec 13 18:14:13 2015 +0000
description:
PR/50547: David Binderman: fix bad sizeof
diffstat:
usr.sbin/sup/source/expand.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diffs (52 lines):
diff -r 80535f8a987d -r 8b4d6397b205 usr.sbin/sup/source/expand.c
--- a/usr.sbin/sup/source/expand.c Sun Dec 13 18:09:00 2015 +0000
+++ b/usr.sbin/sup/source/expand.c Sun Dec 13 18:14:13 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: expand.c,v 1.18 2009/10/17 22:26:13 christos Exp $ */
+/* $NetBSD: expand.c,v 1.19 2015/12/13 18:14:13 christos Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@@ -78,6 +78,7 @@
static jmp_buf sjbuf;
static char pathbuf[MAXPATHLEN];
+static size_t maxpathlen;
static char *path, *pathp, *lastpathp;
static const char globchars[] = "{[*?";/* meta characters */
@@ -104,7 +105,8 @@
{
pathp = path = pathbuf;
*pathp = 0;
- lastpathp = &path[MAXPATHLEN - 2];
+ maxpathlen = sizeof(pathbuf) - 1;
+ lastpathp = &path[maxpathlen];
BUFFER = buffer;
BUFSIZE = bufsize;
bufcnt = 0;
@@ -131,12 +133,11 @@
if (!*cs || *cs == '/') {
if (pathp != path + 1) {
*pathp = 0;
- if (gethdir(path + 1, sizeof path - 1))
+ if (gethdir(path + 1, maxpathlen))
goto endit;
- strncpy(path, path + 1, sizeof path - 1);
+ strlcpy(path, path + 1, maxpathlen);
} else
- strncpy(path, (char *) getenv("HOME"), sizeof path - 1);
- path[sizeof path - 1] = '\0';
+ strlcpy(path, getenv("HOME"), maxpathlen);
pathp = path + strlen(path);
}
}
@@ -398,7 +399,6 @@
if (pp == 0)
return (1);
- strncpy(home, pp->pw_dir, homelen - 1);
- home[homelen - 1] = '\0';
+ strlcpy(home, pp->pw_dir, homelen);
return (0);
}
Home |
Main Index |
Thread Index |
Old Index