svn commit: r253380 - head/lib/libc/stdlib
Andriy Gapon
avg at FreeBSD.org
Wed Jul 17 08:24:59 UTC 2013
on 17/07/2013 07:10 Andrey Chernov said the following:
> On 16.07.2013 11:26, Andriy Gapon wrote:
>> Modified: head/lib/libc/stdlib/getenv.c
>> ==============================================================================
>> --- head/lib/libc/stdlib/getenv.c Tue Jul 16 06:50:22 2013 (r253379)
>> +++ head/lib/libc/stdlib/getenv.c Tue Jul 16 07:26:46 2013 (r253380)
>> @@ -505,7 +505,7 @@ __setenv(const char *name, size_t nameLe
>> 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, "=");
>> }
>>
>
> I am not sure what you are trying to fix, but you just made next line
> condition unpredictable random, since (envVars[envNdx].name)[nameLen] is
> never filled now and there is freshly malloced memory content, which is
> picked for != '=' comparison.
I completely overlooked that check. Thank you for spotting the problema dn
sorry for any potential breakage. I will fix this ASAP.
> Please back it out or fix. Bug demonstration example added will be nice
> too, I see no bug in the original code at first glance.
Sorry if the commit message was not descriptive enough.
I think that this thread should add some context to it:
http://lists.freebsd.org/pipermail/freebsd-tcltk/2013-July/000075.html
Do we already have some regression tests for environment manipulations?
I could add a test for the bug I encountered.
--
Andriy Gapon
More information about the svn-src-all
mailing list