aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/utils.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-03-28 14:12:53 +0100
committerTobias Brunner <tobias@strongswan.org>2013-06-11 11:03:12 +0200
commit7b91011d6edf2febbce28f3d73d149a7f0b81843 (patch)
treebed308306006eb5b033d1db986d1aa9793141bd3 /src/libstrongswan/utils/utils.c
parent438a6693ca54a782342f27f30faa667a4e6612cc (diff)
downloadstrongswan-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.c7
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))