chiark / gitweb /
udev-rules: avoid erroring on trailing whitespace
authorDave Reisner <dreisner@archlinux.org>
Mon, 16 Sep 2013 15:22:35 +0000 (11:22 -0400)
committerDave Reisner <dreisner@archlinux.org>
Mon, 16 Sep 2013 15:46:05 +0000 (11:46 -0400)
https://bugs.archlinux.org/task/36950

src/udev/udev-rules.c

index f14158b5006306ca03de12b035753b33f8932798..6f8b1278723afd30335ad6422a9aa65a357a9e32 100644 (file)
@@ -1068,6 +1068,12 @@ static int add_rule(struct udev_rules *rules, char *line,
                 enum operation_type op;
 
                 if (get_key(rules->udev, &linepos, &key, &op, &value) != 0) {
+                        /* Avoid erroring on trailing whitespace. This is probably rare
+                         * so save the work for the error case instead of always trying
+                         * to strip the trailing whitespace with strstrip(). */
+                        while (isblank(*linepos))
+                                linepos++;
+
                         /* If we aren't at the end of the line, this is a parsing error.
                          * Make a best effort to describe where the problem is. */
                         if (*linepos != '\n') {