From 8335c2a63b5204dbab0575f220075af72e59ea04 Mon Sep 17 00:00:00 2001 From: "Michael K. Johnson" Date: Sun, 21 Sep 1997 16:03:50 +0000 Subject: Fixed allocation bug Erik found, plus a few stylistic points. --- src/usernetctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/usernetctl.c b/src/usernetctl.c index 33bdaf1c..f642f332 100644 --- a/src/usernetctl.c +++ b/src/usernetctl.c @@ -134,7 +134,7 @@ int main(int argc, char ** argv) { /* automatically prepend "ifcfg-" if it is not specified */ if (!strncmp(ifaceConfig, "ifcfg-", 6)) { char *temp; - temp = (char *) malloc(strlen(ifaceConfig) + 6); + temp = (char *) alloca(strlen(ifaceConfig) + 7); strcpy(temp, "ifcfg-"); /* strcat is safe because we got the length from strlen */ strcat(temp, ifaceConfig); @@ -143,7 +143,8 @@ int main(int argc, char ** argv) { switch (userCtl(ifaceConfig)) { - char * dash; + char *dash; + case NOT_FOUND: /* a `-' will be found at least in "ifcfg-" */ dash = strrchr(ifaceConfig, '-'); -- cgit v1.2.1