summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-03-20 03:06:37 +0000
committerngie <ngie@FreeBSD.org>2017-03-20 03:06:37 +0000
commita99c841378467b834a9c58f2df25dba96254cf56 (patch)
tree03aebd3ecc8e7622403474808ed61e063e9efccc /sbin/dhclient
parentf3f74e2cf24a7e337662fdf91836ffd5f3099a15 (diff)
downloadFreeBSD-src-a99c841378467b834a9c58f2df25dba96254cf56.zip
FreeBSD-src-a99c841378467b834a9c58f2df25dba96254cf56.tar.gz
MFC r315199,r315200,r315203:
r315199: sbin/dhclient: fix a memory leak in parse_client_lease_statement(..) The memory stored by `lease` would have previously been leaked if an unterminated lease declaration was found in an early-return code path. CID: 1007114 r315200: Fix -Wunused-but-set-warning with `ret` While here, resolve Coverity warnings by demonstrating that vfprintf's return value is being explicitly ignored. Tested with: clang, gcc 4.2.1, gcc 6.3.0 r315203: sbin/dhclient: fix `vendor` storage leak in parse_option_decl(..) This ensures the storage isn't leaked when non-NULL and the function returns early, prior to the `free(vendor)` later on in the function. CID: 1007111-1007113
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/clparse.c4
-rw-r--r--sbin/dhclient/tests/fake.c5
2 files changed, 6 insertions, 3 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 4f234c7..e735e33 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -510,6 +510,7 @@ parse_client_lease_statement(FILE *cfile, int is_static)
token = peek_token(&val, cfile);
if (token == EOF) {
parse_warn("unterminated lease declaration.");
+ free_client_lease(lease);
return;
}
if (token == RBRACE)
@@ -711,6 +712,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
parse_warn("expecting identifier after '.'");
if (token != SEMI)
skip_to_semi(cfile);
+ free(vendor);
return (NULL);
}
@@ -723,6 +725,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
if (!universe) {
parse_warn("no vendor named %s.", vendor);
skip_to_semi(cfile);
+ free(vendor);
return (NULL);
}
} else {
@@ -744,6 +747,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
parse_warn("no option named %s for vendor %s",
val, vendor);
skip_to_semi(cfile);
+ free(vendor);
return (NULL);
}
diff --git a/sbin/dhclient/tests/fake.c b/sbin/dhclient/tests/fake.c
index c204d49..91bbc6e 100644
--- a/sbin/dhclient/tests/fake.c
+++ b/sbin/dhclient/tests/fake.c
@@ -14,7 +14,7 @@ error(char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ (void)vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
@@ -24,11 +24,10 @@ error(char *fmt, ...)
int
warning(char *fmt, ...)
{
- int ret;
va_list ap;
va_start(ap, fmt);
- ret = vfprintf(stderr, fmt, ap);
+ (void)vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
OpenPOWER on IntegriCloud