dhcpcd-discuss

Re: [PATCH] Fix segfault when reloading the configuration

Roy Marples

Thu Jul 03 10:08:28 2014

On 03/07/2014 10:34, Eelco Dolstra wrote:
Hi,

The following patch fixes a segfault when reloading the configuration:
free_globals() left the ifac/ifdc variables at -1 instead of 0, causing a crash
later in splitv().

--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -143,16 +143,18 @@
 	if (ctx->ifac) {
 		for (ctx->ifac--; ctx->ifac >= 0; ctx->ifac--)
 			free(ctx->ifav[ctx->ifac]);
 		free(ctx->ifav);
 		ctx->ifav = NULL;
+		ctx->ifac = 0;
 	}
 	if (ctx->ifdc) {
 		for (ctx->ifdc--; ctx->ifdc >= 0; ctx->ifdc--)
 			free(ctx->ifdv[ctx->ifdc]);
 		free(ctx->ifdv);
 		ctx->ifdv = NULL;
+		ctx->ifdc = 0;
 	}

 #ifdef INET
 	if (ctx->dhcp_opts) {
 		for (opt = ctx->dhcp_opts;

Committed slightly differently
http://roy.marples.name/projects/dhcpcd/ci/60e4b385d62e450bd34a3e133219dcc0a95835af?sbs=0

Thanks!

Roy

References:
[PATCH] Fix segfault when reloading the configurationEelco Dolstra
Archive administrator: postmaster@marples.name