From 52fa0f80d9b65c7e8d3f2b377fe89ba8e828503b Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 21 Jul 2012 20:12:00 +0200 Subject: [PATCH] conf: fix invalid memory access in strip_spaces() 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 --- src/conf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/conf.c b/src/conf.c index aae439e..8ff2892 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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;