summaryrefslogtreecommitdiff
path: root/src/utils/os_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/os_unix.c')
-rw-r--r--src/utils/os_unix.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 1894fcdb0cf25..800c50772d893 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -1,6 +1,6 @@
/*
* OS specific functions for UNIX/POSIX systems
- * Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2005-2019, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -250,6 +250,13 @@ void os_daemonize_terminate(const char *pid_file)
int os_get_random(unsigned char *buf, size_t len)
{
+#ifdef TEST_FUZZ
+ size_t i;
+
+ for (i = 0; i < len; i++)
+ buf[i] = i & 0xff;
+ return 0;
+#else /* TEST_FUZZ */
FILE *f;
size_t rc;
@@ -266,6 +273,7 @@ int os_get_random(unsigned char *buf, size_t len)
fclose(f);
return rc != len ? -1 : 0;
+#endif /* TEST_FUZZ */
}
@@ -512,7 +520,7 @@ void * os_memdup(const void *src, size_t len)
{
void *r = os_malloc(len);
- if (r)
+ if (r && src)
os_memcpy(r, src, len);
return r;
}