From d6890a7b5390f1f227132be96c0c1ba998b1cdf3 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 20 Jul 2011 04:41:51 +0300 Subject: input: fix input.conf parse errors Commit df899f59be removing a write outside a buffer triggered another problem, as for some reason the code did not 0-terminate its read buffer in the specific case that it had encountered an EOF, and as a result could parse contents left in the buffer for a second time. Usually this resulted in parsing error messages. Fix the problem by rewriting the offending code in a less hacky form. --- bstr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bstr.c') diff --git a/bstr.c b/bstr.c index 68342fabfe..2b40be399c 100644 --- a/bstr.c +++ b/bstr.c @@ -79,12 +79,18 @@ int bstr_find(struct bstr haystack, struct bstr needle) return -1; } -struct bstr bstr_strip(struct bstr str) +struct bstr bstr_lstrip(struct bstr str) { while (str.len && isspace(*str.start)) { str.start++; str.len--; } + return str; +} + +struct bstr bstr_strip(struct bstr str) +{ + str = bstr_lstrip(str); while (str.len && isspace(str.start[str.len - 1])) str.len--; return str; -- cgit v1.2.3