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:
Andriy Gapon 2013-07-16 07:26:46 +00:00
parent 6b06211196
commit e488ee55bc

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, "=");
}