[Olsr-dev] [PATCH v1 11/18] info: protect stripTrailingSlashes against invalid input and zero length

Ferry Huberts (spam-protected)
Sat Dec 10 18:25:21 CET 2016


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/info/olsrd_info.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/info/olsrd_info.c b/lib/info/olsrd_info.c
index fc1597a..e956866 100644
--- a/lib/info/olsrd_info.c
+++ b/lib/info/olsrd_info.c
@@ -606,6 +606,10 @@ static char * stripEOLs(char * requ, size_t *len) {
 }
 
 static char * stripTrailingSlashes(char * requ, size_t *len) {
+  if (!requ || !len || !*len) {
+    return requ;
+  }
+
   while ((requ[*len - 1] == '/') && (requ[*len - 1] != '\0')) {
     *len = *len - 1;
     requ[*len] = '\0';
-- 
2.9.3




More information about the Olsr-dev mailing list