unsigned* linker_env_init(unsigned* vecs) { /* Store environment pointer - can't be NULL */ _envp = (char**) vecs; /* Skip over all definitions */ while (vecs[0] != 0) vecs++; /* The end of the environment block is marked by two NULL pointers */ vecs++; /* As a sanity check, we're going to remove all invalid variable * definitions from the environment array. */ { char** readp = _envp; char** writep = _envp; for ( ; readp[0] != NULL; readp++ ) { if (!_is_valid_definition(readp[0])) continue; writep[0] = readp[0]; writep++; } writep[0] = NULL; } /* Return the address of the aux vectors table */ return vecs; }
static void __remove_invalid_environment_variables() { char** src = _envp; char** dst = _envp; for (; src[0] != NULL; ++src) { if (!_is_valid_definition(src[0])) { continue; } dst[0] = src[0]; ++dst; } dst[0] = NULL; }