diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-02-01 20:07:31 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-02-01 20:07:31 +0000 |
commit | 5487721ba7e5bccb3a572a8469d28b5b007a680d (patch) | |
tree | 47e6ded9e0ed826c4fc2e323d003a7283848e810 /sbin/dhclient/dhclient.c | |
parent | 4f42dcdf7dccfbe0003d25fb86bcbe70ef7c1f0e (diff) |
Increment size of buffer to accomodate terminating NUL *after* using
same variable to determine if cumulative lengths of strings to be
put in buffer are > 0. Otherwise we always think here is something
to put in buffer.
Reported by florian@ and his friend llvm.
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r-- | sbin/dhclient/dhclient.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 2283f9d2f5f..881d7ef222d 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.219 2013/02/01 15:24:55 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.220 2013/02/01 20:07:30 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1959,7 +1959,7 @@ resolv_conf_contents(struct option_data *domainname, } } - len = strlen(dn) + 1; + len = strlen(dn); for (i = 0; i < MAXNS; i++) if (nss[i]) len += strlen(nss[i]); @@ -1970,6 +1970,7 @@ resolv_conf_contents(struct option_data *domainname, if (len == 0) return (NULL); + len++; /* Need room for terminating NUL. */ contents = calloc(1, len); if (contents == NULL) error("no memory for resolv.conf contents"); |