Skip to content
Snippets Groups Projects
Commit 0ea2e15d authored by David Goulet's avatar David Goulet :panda_face:
Browse files

Merge branch 'did-sanity-memmem' into 'main'

add sanity check in tor_memmem

Closes #40854

See merge request tpo/core/tor!785
parents 45c1a36a 0be62789
No related branches found
No related tags found
No related merge requests found
o Minor feature (defense in depth):
- verify needle is smaller than haystack before calling memmem.
Closes ticket 40854.
......@@ -31,6 +31,8 @@ tor_memmem(const void *_haystack, size_t hlen,
{
#if defined(HAVE_MEMMEM) && (!defined(__GNUC__) || __GNUC__ >= 2)
raw_assert(nlen);
if (nlen > hlen)
return NULL;
return memmem(_haystack, hlen, _needle, nlen);
#else
/* This isn't as fast as the GLIBC implementation, but it doesn't need to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment