Re: [PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-25 Thread Matthieu Moy
Jeff King writes: >> diff --git a/wt-status.c b/wt-status.c >> index 435fc28..96a731e 100644 >> --- a/wt-status.c >> +++ b/wt-status.c >> @@ -1317,14 +1317,14 @@ static int grab_1st_switch(unsigned char *osha1, >> unsigned char *nsha1, >> target += strlen(" to "); >> strbuf_reset(&cb->

Re: [PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-25 Thread Jeff King
On Wed, Nov 25, 2015 at 03:16:49AM +0100, René Scharfe wrote: > > Hmm. I think this is mostly harmless, as a comparison like: > > > >memcmp("HEAD and more", "HEAD", strlen("HEAD")) > [...] > > Yes, except it should be strlen("HEAD and more") in your example code; > with strlen("HEAD") it wou

Re: [PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-24 Thread René Scharfe
Am 24.11.2015 um 22:36 schrieb Jeff King: > On Fri, Nov 06, 2015 at 11:47:03PM +0100, René Scharfe wrote: > >> When a branch name is longer than four characters, memcmp() can read >> past the end of the string literal "HEAD". Use strncmp() instead, which >> stops at the end of a string. This fix

Re: [PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-24 Thread Jeff King
On Fri, Nov 06, 2015 at 11:47:03PM +0100, René Scharfe wrote: > When a branch name is longer than four characters, memcmp() can read > past the end of the string literal "HEAD". Use strncmp() instead, which > stops at the end of a string. This fixes the following test failures > with AddressSani

[PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-06 Thread René Scharfe
When a branch name is longer than four characters, memcmp() can read past the end of the string literal "HEAD". Use strncmp() instead, which stops at the end of a string. This fixes the following test failures with AddressSanitizer: t3203-branch-output.sh (Wstat: 256 Te