From: Vladimir Panteleev Date: Tue, 19 Sep 2017 14:37:35 +0000 (+0000) Subject: fake_outputs: Don't read past the end of string X-Git-Tag: 4.15~72^2~2 X-Git-Url: https://git.sur5r.net/?p=i3%2Fi3;a=commitdiff_plain;h=19b00346e5e805cb88ec24c1d29bbd1d292eec14 fake_outputs: Don't read past the end of string fake_outputs_init would unconditionally increase the string read pointer variable (walk) by one character more than the number of characters that have been read, to skip past the character delimiting records (a comma). However, when the input string was not terminated by a comma, it would cause the function to read past the null terminator instead. Avoid this by explicitly checking for the expected delimiter. --- diff --git a/src/fake_outputs.c b/src/fake_outputs.c index 447409d2..64c3e20c 100644 --- a/src/fake_outputs.c +++ b/src/fake_outputs.c @@ -68,7 +68,9 @@ void fake_outputs_init(const char *output_spec) { num_screens++; } - walk += chars_consumed + 1; + walk += chars_consumed; + if (*walk == ',') + walk++; } if (num_screens == 0) {