diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-30 05:05:31 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-30 05:05:31 +0000 |
commit | 76ddc2e3e4837d0557fb6626394f87648e5f8c3b (patch) | |
tree | f545fe36c1ebc20c743ab28bc0df2b0f1d28b59d /miscutils/crond.c | |
parent | d6e8f9450cf055f0abfa424c5aa9e5a7c30d6593 (diff) | |
download | busybox-w32-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.tar.gz busybox-w32-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.tar.bz2 busybox-w32-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.zip |
libbb: add bb_unsetenv (taken from hush).
udhcpc: stop filtering environment passed to the script.
crond: fix uncovered potential bug (failing unsetenv)
mdev: fix uncovered potential bug (failing unsetenv)
tcp, udpsvd: fix uncovered potential bug (failing unsetenv)
function old new delta
safe_setenv - 58 +58
bb_unsetenv - 55 +55
builtin_unset 139 138 -1
tcpudpsvd_main 1843 1830 -13
free_strings_and_unsetenv 87 53 -34
udhcp_run_script 1186 1133 -53
safe_setenv4 62 - -62
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/4 up/down: 113/-163) Total: -50 bytes
Diffstat (limited to 'miscutils/crond.c')
-rw-r--r-- | miscutils/crond.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index 732fbb147..12560fa36 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
@@ -252,14 +252,12 @@ int crond_main(int argc UNUSED_PARAM, char **argv) | |||
252 | /* We set environment *before* vfork (because we want to use vfork), | 252 | /* We set environment *before* vfork (because we want to use vfork), |
253 | * so we cannot use setenv() - repeated calls to setenv() may leak memory! | 253 | * so we cannot use setenv() - repeated calls to setenv() may leak memory! |
254 | * Using putenv(), and freeing memory after unsetenv() won't leak */ | 254 | * Using putenv(), and freeing memory after unsetenv() won't leak */ |
255 | static void safe_setenv4(char **pvar_val, const char *var, const char *val /*, int len*/) | 255 | static void safe_setenv(char **pvar_val, const char *var, const char *val) |
256 | { | 256 | { |
257 | const int len = 4; /* both var names are 4 char long */ | ||
258 | char *var_val = *pvar_val; | 257 | char *var_val = *pvar_val; |
259 | 258 | ||
260 | if (var_val) { | 259 | if (var_val) { |
261 | var_val[len] = '\0'; /* nuke '=' */ | 260 | bb_unsetenv(var_val); |
262 | unsetenv(var_val); | ||
263 | free(var_val); | 261 | free(var_val); |
264 | } | 262 | } |
265 | *pvar_val = xasprintf("%s=%s", var, val); | 263 | *pvar_val = xasprintf("%s=%s", var, val); |
@@ -270,10 +268,10 @@ static void safe_setenv4(char **pvar_val, const char *var, const char *val /*, i | |||
270 | static void SetEnv(struct passwd *pas) | 268 | static void SetEnv(struct passwd *pas) |
271 | { | 269 | { |
272 | #if SETENV_LEAKS | 270 | #if SETENV_LEAKS |
273 | safe_setenv4(&env_var_user, "USER", pas->pw_name); | 271 | safe_setenv(&env_var_user, "USER", pas->pw_name); |
274 | safe_setenv4(&env_var_home, "HOME", pas->pw_dir); | 272 | safe_setenv(&env_var_home, "HOME", pas->pw_dir); |
275 | /* if we want to set user's shell instead: */ | 273 | /* if we want to set user's shell instead: */ |
276 | /*safe_setenv(env_var_user, "SHELL", pas->pw_shell, 5);*/ | 274 | /*safe_setenv(env_var_user, "SHELL", pas->pw_shell);*/ |
277 | #else | 275 | #else |
278 | xsetenv("USER", pas->pw_name); | 276 | xsetenv("USER", pas->pw_name); |
279 | xsetenv("HOME", pas->pw_dir); | 277 | xsetenv("HOME", pas->pw_dir); |