mailing list of musl libc
 help / color / mirror / code / Atom feed
* uninitialized memory access in memmem()
@ 2014-06-18 18:20 Clément Vasseur
  2014-06-19  1:06 ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: Clément Vasseur @ 2014-06-18 18:20 UTC (permalink / raw)
  To: musl

Hello,

I found a case where memmem() returns 0 where it should not:

$ cat test-memmem.c
#define _GNU_SOURCE
#include <string.h>
#include <assert.h>

#define DATA 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10

int main(void)
{
    const unsigned char haystack[] = { DATA };
    const unsigned char needle[] = { DATA };
    assert(memmem(haystack, sizeof haystack, needle, sizeof needle));
}

$ musl-gcc test-memmem.c && ./a.out
Assertion failed: memmem(haystack, sizeof haystack, needle, sizeof needle) (test-memmem.c: main: 11)
Aborted

Valgrind says a conditional jump or move depends on uninitalized value
in twoway_memmem(). The code is quite complicated so I have not tried to
track it down any further.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-19  4:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 18:20 uninitialized memory access in memmem() Clément Vasseur
2014-06-19  1:06 ` Rich Felker
2014-06-19  1:43   ` Clément Vasseur
2014-06-19  3:18     ` Rich Felker
2014-06-19  3:56     ` Rich Felker
2014-06-19  4:48       ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).