diff options
author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1999-02-01 16:35:40 +0000 |
---|---|---|
committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1999-02-01 16:35:40 +0000 |
commit | 750eba274b90b627b65a6a06f7b1c70c20054b89 (patch) | |
tree | 1eb25b3c69b5d40ceb365695845593518a75c1fd /usr.sbin | |
parent | 8db502bbfdcb965a862728a85aa66f4c931d3582 (diff) | |
download | src-750eba274b90b627b65a6a06f7b1c70c20054b89.tar.gz src-750eba274b90b627b65a6a06f7b1c70c20054b89.zip |
Man, was I ever smoking crack when I wrote this. Don't free()
values I'm going to use again. :-}
Notes
Notes:
svn path=/head/; revision=43502
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sade/config.c | 14 | ||||
-rw-r--r-- | usr.sbin/sysinstall/config.c | 14 |
2 files changed, 12 insertions, 16 deletions
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index d6614695df66..59ae131b9154 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.116 1999/01/27 02:32:46 jkh Exp $ + * $Id: config.c,v 1.117 1999/01/30 22:15:36 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -395,13 +395,11 @@ configRC_conf(char *config) for (v = VarHead; v; v = v->next) { for (i = 0; i < nlines; i++) { /* Skip the comments & non-variable settings */ - if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) { - free(lines[i]); + if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) continue; - } len = strlen(v->name); - if (!strncmp(lines[i], v->name, cp - lines[i]) && (cp - lines[i]) == len) { + if (!strncmp(lines[i], v->name, cp - lines[i]) && (cp - lines[i]) == len && strcmp(cp + 1, v->value)) { char *cp2, *comment = NULL; /* If trailing comment, try and preserve it */ @@ -415,7 +413,7 @@ configRC_conf(char *config) } } free(lines[i]); - lines[i] = (char *)alloca(strlen(v->name) + strlen(v->value) + (comment ? strlen(comment) : 0) + 10); + lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? strlen(comment) : 0) + 10); if (comment) sprintf(lines[i], "%s=\"%s\"%s", v->name, v->value, comment); else @@ -454,10 +452,10 @@ configRC_conf(char *config) } } } - else - free(lines[i]); } } + for (i = 0; i < nlines; i++) + free(lines[i]); fclose(rcSite); } diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c index d6614695df66..59ae131b9154 100644 --- a/usr.sbin/sysinstall/config.c +++ b/usr.sbin/sysinstall/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.116 1999/01/27 02:32:46 jkh Exp $ + * $Id: config.c,v 1.117 1999/01/30 22:15:36 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -395,13 +395,11 @@ configRC_conf(char *config) for (v = VarHead; v; v = v->next) { for (i = 0; i < nlines; i++) { /* Skip the comments & non-variable settings */ - if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) { - free(lines[i]); + if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) continue; - } len = strlen(v->name); - if (!strncmp(lines[i], v->name, cp - lines[i]) && (cp - lines[i]) == len) { + if (!strncmp(lines[i], v->name, cp - lines[i]) && (cp - lines[i]) == len && strcmp(cp + 1, v->value)) { char *cp2, *comment = NULL; /* If trailing comment, try and preserve it */ @@ -415,7 +413,7 @@ configRC_conf(char *config) } } free(lines[i]); - lines[i] = (char *)alloca(strlen(v->name) + strlen(v->value) + (comment ? strlen(comment) : 0) + 10); + lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? strlen(comment) : 0) + 10); if (comment) sprintf(lines[i], "%s=\"%s\"%s", v->name, v->value, comment); else @@ -454,10 +452,10 @@ configRC_conf(char *config) } } } - else - free(lines[i]); } } + for (i = 0; i < nlines; i++) + free(lines[i]); fclose(rcSite); } |