Date: Mon, 20 Mar 2017 03:06:41 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r315610 - in stable/10/sbin/dhclient: . tests Message-ID: <201703200306.v2K36fcn079404@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Mon Mar 20 03:06:41 2017 New Revision: 315610 URL: https://svnweb.freebsd.org/changeset/base/315610 Log: 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 Modified: stable/10/sbin/dhclient/clparse.c stable/10/sbin/dhclient/tests/fake.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dhclient/clparse.c ============================================================================== --- stable/10/sbin/dhclient/clparse.c Mon Mar 20 03:06:37 2017 (r315609) +++ stable/10/sbin/dhclient/clparse.c Mon Mar 20 03:06:41 2017 (r315610) @@ -510,6 +510,7 @@ parse_client_lease_statement(FILE *cfile 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 op 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 op 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 op parse_warn("no option named %s for vendor %s", val, vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } Modified: stable/10/sbin/dhclient/tests/fake.c ============================================================================== --- stable/10/sbin/dhclient/tests/fake.c Mon Mar 20 03:06:37 2017 (r315609) +++ stable/10/sbin/dhclient/tests/fake.c Mon Mar 20 03:06:41 2017 (r315610) @@ -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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703200306.v2K36fcn079404>