dhcpcd-discuss

[PATCH] Fix segfault when reloading the configuration

Eelco Dolstra

Thu Jul 03 09:34:16 2014

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;

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/

Follow-Ups:
Re: [PATCH] Fix segfault when reloading the configurationRoy Marples
Archive administrator: postmaster@marples.name