chiark / gitweb /
fix symlink values separated by multiple spaces
[elogind.git] / udev_rules.c
index 27fb0a89a607065207e689d995f07433314b4b83..a25c2e90a8bc196b6f3a44a219b339a01505c74b 100644 (file)
@@ -31,6 +31,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/wait.h>
+#include <sys/stat.h>
 
 #include "libsysfs/sysfs/libsysfs.h"
 #include "list.h"
@@ -957,16 +958,22 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev, struct s
 
                                /* add multiple symlinks separated by spaces */
                                pos = temp;
-                               next = strchr(temp, ' ');
+                               while (isspace(pos[0]))
+                                       pos++;
+                               next = strchr(pos, ' ');
                                while (next) {
                                        next[0] = '\0';
                                        info("add symlink '%s'", pos);
                                        name_list_add(&udev->symlink_list, pos, 0);
+                                       while (isspace(next[1]))
+                                               next++;
                                        pos = &next[1];
                                        next = strchr(pos, ' ');
                                }
-                               info("add symlink '%s'", pos);
-                               name_list_add(&udev->symlink_list, pos, 0);
+                               if (pos[0] != '\0') {
+                                       info("add symlink '%s'", pos);
+                                       name_list_add(&udev->symlink_list, pos, 0);
+                               }
                        }
 
                        /* set name, later rules with name set will be ignored */