]> git.sur5r.net Git - i3/i3/commitdiff
fake_outputs: Don't read past the end of string
authorVladimir Panteleev <git@thecybershadow.net>
Tue, 19 Sep 2017 14:37:35 +0000 (14:37 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 19 Sep 2017 16:58:28 +0000 (18:58 +0200)
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.

src/fake_outputs.c

index 447409d2a024503f6f83cd6d494070349b66d88a..64c3e20c7866145497a2a23f9a5bf0ea4adc1b51 100644 (file)
@@ -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) {