From: Ferry Huberts Date: Thu, 8 Dec 2016 07:49:08 +0000 (+0100) Subject: info: protect stripTrailingSlashes against invalid input and zero length X-Git-Tag: v0.9.6~55 X-Git-Url: http://olsr.org/git/?p=olsrd.git;a=commitdiff_plain;h=8560212cbb078b992a5cb3f2fa50bf845442cbc6 info: protect stripTrailingSlashes against invalid input and zero length Signed-off-by: Ferry Huberts --- diff --git a/lib/info/olsrd_info.c b/lib/info/olsrd_info.c index fc1597a3..e956866f 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';