teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0024-udev-rules-avoid-erroring-on-trailing-whitespace.patch

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