diff options
| author | 1996-08-27 03:32:53 +0000 | |
|---|---|---|
| committer | 1996-08-27 03:32:53 +0000 | |
| commit | 5160187f93f725e945f4c2c21a7bb741ea57c2cc (patch) | |
| tree | 7b2b95076d989206821fef5eef1f23234c648d97 /lib/libc/net/res_init.c | |
| parent | Ensure strings are NUL terminated after strncpy (diff) | |
| download | wireguard-openbsd-5160187f93f725e945f4c2c21a7bb741ea57c2cc.tar.xz wireguard-openbsd-5160187f93f725e945f4c2c21a7bb741ea57c2cc.zip | |
use strncpy correctly
Diffstat (limited to 'lib/libc/net/res_init.c')
| -rw-r--r-- | lib/libc/net/res_init.c | 5 |
1 files changed, 4 insertions, 1 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'; /* |
