a4b143
From c4f1b97f45f1685c0a4bcba8c6724ce17bb6af19 Mon Sep 17 00:00:00 2001
a4b143
From: Dave Reisner <dreisner@archlinux.org>
a4b143
Date: Mon, 16 Sep 2013 11:22:35 -0400
a4b143
Subject: [PATCH] udev-rules: avoid erroring on trailing whitespace
a4b143
a4b143
https://bugs.archlinux.org/task/36950
a4b143
---
a4b143
 src/udev/udev-rules.c | 6 ++++++
a4b143
 1 file changed, 6 insertions(+)
a4b143
a4b143
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
a4b143
index f14158b..6f8b127 100644
a4b143
--- a/src/udev/udev-rules.c
a4b143
+++ b/src/udev/udev-rules.c
a4b143
@@ -1068,6 +1068,12 @@ static int add_rule(struct udev_rules *rules, char *line,
a4b143
                 enum operation_type op;
a4b143
 
a4b143
                 if (get_key(rules->udev, &linepos, &key, &op, &value) != 0) {
a4b143
+                        /* Avoid erroring on trailing whitespace. This is probably rare
a4b143
+                         * so save the work for the error case instead of always trying
a4b143
+                         * to strip the trailing whitespace with strstrip(). */
a4b143
+                        while (isblank(*linepos))
a4b143
+                                linepos++;
a4b143
+
a4b143
                         /* If we aren't at the end of the line, this is a parsing error.
a4b143
                          * Make a best effort to describe where the problem is. */
a4b143
                         if (*linepos != '\n') {