aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/utils.c
diff options
context:
space:
mode:
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))