diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-28 17:55:27 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-28 17:55:27 +0200 |
commit | 405095d84b1f3be17efb4e10d87d480bd054877f (patch) | |
tree | 2af92e403edf9ef0f0afe072ad6f70c63fd24d5a /networking/ifupdown.c | |
parent | 7b93e317c13053e40e76cc5c36404f92d05dd41c (diff) | |
download | busybox-w32-405095d84b1f3be17efb4e10d87d480bd054877f.tar.gz busybox-w32-405095d84b1f3be17efb4e10d87d480bd054877f.tar.bz2 busybox-w32-405095d84b1f3be17efb4e10d87d480bd054877f.zip |
ifupdown: close memory leak
function old new delta
execute_all 80 91 +11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | networking/ifupdown.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 8a6efc976..5327b0979 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1177,8 +1177,15 @@ static int doit(char *str) | |||
1177 | 1177 | ||
1178 | static int execute_all(struct interface_defn_t *ifd, const char *opt) | 1178 | static int execute_all(struct interface_defn_t *ifd, const char *opt) |
1179 | { | 1179 | { |
1180 | /* 'opt' is always short, the longest value is "post-down". | ||
1181 | * Can use on-stack buffer instead of xasprintf'ed one. | ||
1182 | */ | ||
1183 | char buf[sizeof("run-parts /etc/network/if-%s.d") | ||
1184 | + sizeof("post-down") | ||
1185 | /*paranoia:*/ + 8 | ||
1186 | ]; | ||
1180 | int i; | 1187 | int i; |
1181 | char *buf; | 1188 | |
1182 | for (i = 0; i < ifd->n_options; i++) { | 1189 | for (i = 0; i < ifd->n_options; i++) { |
1183 | if (strcmp(ifd->option[i].name, opt) == 0) { | 1190 | if (strcmp(ifd->option[i].name, opt) == 0) { |
1184 | if (!doit(ifd->option[i].value)) { | 1191 | if (!doit(ifd->option[i].value)) { |
@@ -1192,8 +1199,7 @@ static int execute_all(struct interface_defn_t *ifd, const char *opt) | |||
1192 | * complains, and this message _is_ annoyingly visible. | 1199 | * complains, and this message _is_ annoyingly visible. |
1193 | * Don't "fix" this (unless newer Debian does). | 1200 | * Don't "fix" this (unless newer Debian does). |
1194 | */ | 1201 | */ |
1195 | buf = xasprintf("run-parts /etc/network/if-%s.d", opt); | 1202 | sprintf(buf, "run-parts /etc/network/if-%s.d", opt); |
1196 | /* heh, we don't bother free'ing it */ | ||
1197 | return doit(buf); | 1203 | return doit(buf); |
1198 | } | 1204 | } |
1199 | 1205 | ||