aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-30 05:05:31 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-30 05:05:31 +0000
commit76ddc2e3e4837d0557fb6626394f87648e5f8c3b (patch)
treef545fe36c1ebc20c743ab28bc0df2b0f1d28b59d /miscutils
parentd6e8f9450cf055f0abfa424c5aa9e5a7c30d6593 (diff)
downloadbusybox-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.tar.gz
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')
-rw-r--r--miscutils/crond.c12
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)
/* We set environment *before* vfork (because we want to use vfork),
* so we cannot use setenv() - repeated calls to setenv() may leak memory!
* Using putenv(), and freeing memory after unsetenv() won't leak */
-static void safe_setenv4(char **pvar_val, const char *var, const char *val /*, int len*/)
+static void safe_setenv(char **pvar_val, const char *var, const char *val)
{
- const int len = 4; /* both var names are 4 char long */
char *var_val = *pvar_val;
if (var_val) {
- var_val[len] = '\0'; /* nuke '=' */
- unsetenv(var_val);
+ bb_unsetenv(var_val);
free(var_val);
}
*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
static void SetEnv(struct passwd *pas)
{
#if SETENV_LEAKS
- safe_setenv4(&env_var_user, "USER", pas->pw_name);
- safe_setenv4(&env_var_home, "HOME", pas->pw_dir);
+ safe_setenv(&env_var_user, "USER", pas->pw_name);
+ safe_setenv(&env_var_home, "HOME", pas->pw_dir);
/* if we want to set user's shell instead: */
- /*safe_setenv(env_var_user, "SHELL", pas->pw_shell, 5);*/
+ /*safe_setenv(env_var_user, "SHELL", pas->pw_shell);*/
#else
xsetenv("USER", pas->pw_name);
xsetenv("HOME", pas->pw_dir);