conf: fix invalid memory access in strip_spaces()
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 21 Jul 2012 18:12:00 +0000 (20:12 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 21 Jul 2012 18:12:00 +0000 (20:12 +0200)
We must not assume that the string is longer than 0 characters. Therefore,
check whether we would access invalid memory before the string when
removing trailing whitespaces.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/conf.c

index aae439e..8ff2892 100644 (file)
@@ -385,6 +385,9 @@ static void strip_spaces(char **buf)
        while (**buf == ' ' || **buf == '\r' || **buf == '\t')
                ++*buf;
 
+       if (!**buf)
+               return;
+
        tail = *buf;
        while (*tail)
                ++tail;