author | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2014-08-05 11:13:28 (GMT) |
---|---|---|
committer | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2014-08-05 11:13:28 (GMT) |
commit | 3ae2578282187c775247cb2c3cc9f442d9c138e0 (patch) | |
tree | 8d1cf26b8758286535616833dec013fbad9993aa | |
parent | b0919fd5afe40d5855bb4c77f6a7d985a541d20c (diff) | |
download | busybox-3ae2578282187c775247cb2c3cc9f442d9c138e0.zip busybox-3ae2578282187c775247cb2c3cc9f442d9c138e0.tar.gz busybox-3ae2578282187c775247cb2c3cc9f442d9c138e0.tar.bz2 |
android: clearenv should not set environ to NULL
Remove the old internal clearenv() function which is
no more required (exported in libc)
Change-Id: I357f6a3b057c366761b481c09b471d7c53d7a419
-rw-r--r-- | android/android.c | 16 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 5 |
2 files changed, 18 insertions, 3 deletions
diff --git a/android/android.c b/android/android.c index 7d191c9..62d25a8 100644 --- a/android/android.c +++ b/android/android.c @@ -10,12 +10,22 @@ #include <stdlib.h> #include "libbb.h" -/* declared in stdlib.h */ -int clearenv() +#ifndef BIONIC_ICS +int clearenv(void) { - environ = NULL; + char **P = environ; + + /* should never be NULL */ + if (!environ) + environ = (char **)xzalloc(sizeof(char *)); + + if (P != NULL) { + for (; *P; ++P) + *P = NULL; + } return 0; } +#endif /* no /etc/shells anyway */ char *getusershell() { return NULL; } diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 7a9581d..7fb34e1 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -322,6 +322,11 @@ char* FAST_FUNC xasprintf(const char *format, ...) void FAST_FUNC xsetenv(const char *key, const char *value) { +#ifdef __BIONIC__ + /* on login, can be NULL, and should not be for bionic */ + if (environ == NULL) + bb_error_msg_and_die("environment is not initialized"); +#endif if (setenv(key, value, 1)) bb_error_msg_and_die("%s", bb_msg_memory_exhausted); } |