diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 03:32:55 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 03:32:55 +0000 |
commit | 7299897e474ec70fa715c574d2703640a352705a (patch) | |
tree | 14cd6b9b5beb7c8f2cb4dc3ee5676c74702b2f88 /lib/libc | |
parent | 435a38d9dfc2ff6b7444727e9da4e521828bfbec (diff) |
use strncpy correctly
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/res_init.c | 5 | ||||
-rw-r--r-- | lib/libc/net/res_query.c | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c index c925236869e..cb60d4c0df1 100644 --- a/lib/libc/net/res_init.c +++ b/lib/libc/net/res_init.c @@ -52,7 +52,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: res_init.c,v 1.5 1996/08/25 10:11:02 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: res_init.c,v 1.6 1996/08/27 03:32:53 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -131,6 +131,7 @@ res_init() /* Allow user to override the local domain definition */ if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) { (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); + _res.defdname[sizeof(_res.defdname) - 1] = '\0'; if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) *cp = '\0'; haveenv++; @@ -183,6 +184,7 @@ res_init() continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); + _res.defdname[sizeof(_res.defdname) - 1] = '\0'; if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) *cp = '\0'; havesearch = 0; @@ -226,6 +228,7 @@ res_init() continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); + _res.defdname[sizeof(_res.defdname) - 1] = '\0'; if ((cp = strchr(_res.defdname, '\n')) != NULL) *cp = '\0'; /* diff --git a/lib/libc/net/res_query.c b/lib/libc/net/res_query.c index 8fa987ad6b6..fb2d22c1192 100644 --- a/lib/libc/net/res_query.c +++ b/lib/libc/net/res_query.c @@ -52,7 +52,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: res_query.c,v 1.6 1996/08/24 09:32:20 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: res_query.c,v 1.7 1996/08/27 03:32:54 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -379,8 +379,8 @@ __hostalias(name) break; for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2) ; - abuf[sizeof(abuf) - 1] = *cp2 = '\0'; (void)strncpy(abuf, cp1, sizeof(abuf) - 1); + abuf[sizeof(abuf) - 1] = *cp2 = '\0'; fclose(fp); return (abuf); } |