diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-03-28 14:12:53 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-06-11 11:03:12 +0200 |
commit | 7b91011d6edf2febbce28f3d73d149a7f0b81843 (patch) | |
tree | bed308306006eb5b033d1db986d1aa9793141bd3 /src/libstrongswan/utils/utils.c | |
parent | 438a6693ca54a782342f27f30faa667a4e6612cc (diff) | |
download | strongswan-7b91011d6edf2febbce28f3d73d149a7f0b81843.tar.bz2 strongswan-7b91011d6edf2febbce28f3d73d149a7f0b81843.tar.xz |
Allow memstr() to be called with NULL arguments
Diffstat (limited to 'src/libstrongswan/utils/utils.c')
-rw-r--r-- | src/libstrongswan/utils/utils.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c index ba32720ea..aa59f4a4d 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)) |