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

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


From: Ferry Huberts <(spam-protected)>

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

diff --git a/lib/info/olsrd_info.c b/lib/info/olsrd_info.c
index e956866..8b58009 100644
--- a/lib/info/olsrd_info.c
+++ b/lib/info/olsrd_info.c
@@ -620,6 +620,11 @@ static char * stripTrailingSlashes(char * requ, size_t *len) {
 static char * cutAtFirstEOL(char * requ, size_t *len) {
   char * s = requ;
   size_t l = 0;
+
+  if (!requ || !len || !*len) {
+    return requ;
+  }
+
   while (!((*s == '\n') || (*s == '\r')) && (*s != '\0')) {
     s++;
     l++;
-- 
2.9.3




More information about the Olsr-dev mailing list