info: protect stripEOLs against invalid input and zero length
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 7 Dec 2016 23:12:16 +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 43170b8..1f431b7 100644 (file)
@@ -588,6 +588,10 @@ static char * skipLeadingWhitespace(char * requ, size_t *len) {
 }
 
 static char * stripEOLs(char * requ, size_t *len) {
+  if (!requ || !len || !*len) {
+    return requ;
+  }
+
   while (isspace(requ[*len - 1]) && (requ[*len - 1] != '\0')) {
     *len = *len - 1;
     requ[*len] = '\0';