From 7e431900a587dfddae00eb265b6c395297eb8799 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Mar 2017 17:45:00 +0000 Subject: [PATCH] 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. MFC after: 1 week Reported by: Coverity CID: 1007111-1007113 Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: D9993 --- sbin/dhclient/clparse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 9dcc8f2dcfeb..a03723f7256b 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -714,6 +714,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); } @@ -726,6 +727,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 { @@ -747,6 +749,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); }