chiark / gitweb /
fix off by one error in array index assertion
authorDave Reisner <dreisner@archlinux.org>
Sat, 8 Mar 2014 22:32:53 +0000 (17:32 -0500)
committerDave Reisner <dreisner@archlinux.org>
Sat, 8 Mar 2014 22:57:18 +0000 (17:57 -0500)
Since the index is already post-incremented when the array is appended
to, this assertion can be wrongly reached when the array is at capacity
(with the NULL terminator). The bug is reproducible on shutdown with
the following settings in /etc/systemd/system.conf:

  LogTarget=journal-or-kmsg
  LogColor=yes
  LogLocation=yes

Reported by Thermi on IRC.

src/core/main.c

index 6ebfe64187d994916de8c9479e64100a8136d1a7..f1b06d88803e85ef72f507df1b9fb9d5bbe9878d 100644 (file)
@@ -1994,7 +1994,7 @@ finish:
                 if (log_get_show_location())
                         command_line[pos++] = "--log-location";
 
-                assert(pos + 1 < ELEMENTSOF(command_line));
+                assert(pos < ELEMENTSOF(command_line));
 
                 if (arm_reboot_watchdog && arg_shutdown_watchdog > 0) {
                         char *e;