From: Tobias Brunner Date: Thu, 28 Mar 2013 13:12:53 +0000 (+0100) Subject: Allow memstr() to be called with NULL arguments X-Git-Tag: 5.1.0dr1~129^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b91011d6edf2febbce28f3d73d149a7f0b81843;p=thirdparty%2Fstrongswan.git Allow memstr() to be called with NULL arguments --- diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c index ba32720ea2..aa59f4a4dc 100644 --- a/src/libstrongswan/utils/utils.c +++ b/src/libstrongswan/utils/utils.c @@ -102,7 +102,12 @@ void memwipe_noinline(void *ptr, size_t n) void *memstr(const void *haystack, const char *needle, size_t n) { unsigned const char *pos = haystack; - size_t l = strlen(needle); + size_t l; + + if (!haystack || !needle || (l = strlen(needle)) == 0) + { + return NULL; + } for (; n >= l; ++pos, --n) { if (memeq(pos, needle, l))