aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael K. Johnson <johnsonm@redhat.com>1997-09-21 16:03:50 +0000
committerMichael K. Johnson <johnsonm@redhat.com>1997-09-21 16:03:50 +0000
commit8335c2a63b5204dbab0575f220075af72e59ea04 (patch)
tree3ce2a39bc4f53797fb9ea5374b7cbb228c6f95df
parent995387d1f852c4301ef0685a91d3df38f4bcdc36 (diff)
downloadinitscripts-8335c2a63b5204dbab0575f220075af72e59ea04.tar
initscripts-8335c2a63b5204dbab0575f220075af72e59ea04.tar.gz
initscripts-8335c2a63b5204dbab0575f220075af72e59ea04.tar.bz2
initscripts-8335c2a63b5204dbab0575f220075af72e59ea04.tar.xz
initscripts-8335c2a63b5204dbab0575f220075af72e59ea04.zip
Fixed allocation bug Erik found, plus a few stylistic points.
-rw-r--r--src/usernetctl.c5
1 files changed, 3 insertions, 2 deletions
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, '-');