libc: name passed into __setenv is not necessarily NUL-terminated

That's particularly true when __setenv is called from __merge_environ.

MFC after:	4 days
This commit is contained in:
avg 2013-07-16 07:26:46 +00:00
parent 5b5efe4af0
commit 1afb4f2886

View File

@ -505,7 +505,7 @@ __setenv(const char *name, size_t nameLen, const char *value, int overwrite)
envVars[envNdx].valueSize = valueLen;
/* Save name of name/value pair. */
env = stpcpy(envVars[envNdx].name, name);
env = stpncpy(envVars[envNdx].name, name, nameLen);
if ((envVars[envNdx].name)[nameLen] != '=')
env = stpcpy(env, "=");
}