[BusyBox] memory leak in execute_all

Sauder, Vernon Vernon.Sauder at spirentcom.com
Mon May 3 19:44:31 UTC 2004


In networking/ifupdown.c, there is a function called execute_all() which
seems to have a memory leak. I can find no evidence of a memory deallocation
for buf. bb_xasprintf will allocate memory to buf via vasprintf but the man
page says that buf should be handed to free when done with it.

static int execute_all(struct interface_defn_t *ifd, execfn *exec, const
char *opt)
{
	int i;
	char *buf;
	for (i = 0; i < ifd->n_options; i++) {
		if (strcmp(ifd->option[i].name, opt) == 0) {
			if (!(*exec) (ifd->option[i].value)) {
				return 0;
			}
		}
	}

	bb_xasprintf(&buf, "run-parts /etc/network/if-%s.d", opt);
	(*exec)(buf);

	return (1);
}


Vernon Sauder
Spirent Communications, Inc.
www.spirentcom.com



More information about the busybox mailing list