info: protect skipLeadingWhitespace against invalid input and zero length
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 7 Dec 2016 23:12:37 +0000 (00:12 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 4 Jan 2017 08:47:10 +0000 (09:47 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/info/olsrd_info.c

index 5dfa62f..fc1597a 100644 (file)
@@ -582,6 +582,10 @@ static void send_info(const char * req, unsigned int send_what, int the_socket,
 }
 
 static char * skipLeadingWhitespace(char * requ, size_t *len) {
+  if (!requ || !len || !*len) {
+    return requ;
+  }
+
   while (isspace(*requ) && (*requ != '\0')) {
     *len = *len - 1;
     requ++;