public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Should memchr work with invalid data size?
@ 2017-05-17 22:24 H.J. Lu
  2017-05-18  4:22 ` Carlos O'Donell
  2017-05-18  5:53 ` Florian Weimer
  0 siblings, 2 replies; 6+ messages in thread
From: H.J. Lu @ 2017-05-17 22:24 UTC (permalink / raw)
  To: GNU C Library

"main memchr" says

The  memchr()  function  scans  the  initial n bytes of the memory area
pointed to by s for the first instance of c.

But test-memchr.c has

      if (pos < len)
        {
          size_t r = random ();
          if ((r & 31) == 0)
            len = ~(uintptr_t) (p + align) - ((r >> 5) & 31);
          result = (CHAR *) (p + pos + align);
        }

which sets len to some random value, like 18446603336355475958.
Should memchr work with it?


-- 
H.J.

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

end of thread, other threads:[~2017-05-18 14:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 22:24 Should memchr work with invalid data size? H.J. Lu
2017-05-18  4:22 ` Carlos O'Donell
2017-05-18  5:53 ` Florian Weimer
2017-05-18  6:42   ` Florian Weimer
2017-05-18  7:42   ` Andreas Schwab
2017-05-18 14:12     ` Adhemerval Zanella

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 read-only IMAP folder(s) and NNTP newsgroup(s).