RFR(S): 8252407: Build failure with gcc-8+ and asan
Kim Barrett
kim.barrett at oracle.com
Tue Sep 8 12:29:42 UTC 2020
> On Sep 7, 2020, at 5:55 AM, Florian Weimer <fweimer at redhat.com> wrote:
>
> * Kim Barrett:
>
>> And strlen is not even necessarily the best solution, as it likely
>> introduces an additional otherwise unnecessary string traversal. For
>> example, getFlags could be changed to reject an overly long ifname,
>> without using strlen, thusly:
>>
>> strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name));
>> if (if2.ifr_name[sizeof(if2.ifr_name) - 1] != '\0') {
>> return -1;
>> }
>>
>> Unfortunately, gcc10 -Wstringop-truncation whines about this entirely
>> reasonable code.
>
> Thanks, I filed this as: <https://urldefense.com/v3/__https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96951__;!!GqivPVa7Brio!LVecE16VyMwNW6-aTnJEfSMgHgOZDIrswH8f0svlQJWAQfrOqqXaq-i7q508_5Eb$ >
Thanks. Though it looks like the response is just “don’t use strncpy”.
More information about the net-dev
mailing list