From: René Scharfe Date: Sat, 08 Jul 2017 11:43:02 GMT Subject: Re: [PATCH] apply: use strcmp(3) for comparing strings in gitdiff_verify_name() Message-ID: In-Reply-To: <87tw2ngp94.fsf@linux-m68k.org> Am 08.07.2017 um 13:08 schrieb Andreas Schwab: > On Jul 08 2017, René Scharfe wrote: > >> Avoid running over the end of another -- a C string whose length we >> don't know -- by using strcmp(3) instead of memcmp(3) for comparing it >> with another C string. > > That's not a good justification for the change, since memcmp never reads > past the differing characters. Interesting. Where does that guarantee come from? ASan reports an overflow with the following test program for me on Debian testing x64: #include int main(int argc, char **argv) { char a[32] = "1234567890123456789012345678901"; char b[2] = "a"; return memcmp(a, b, 32); }