Re: [systemd-devel] [PATCH] udevadm hwdb: discard extra leading whitespaces in hwdb
On Thu, Nov 27, 2014 at 07:21:55AM +0100, Zbigniew Jędrzejewski-Szmek wrote: On Wed, Nov 26, 2014 at 09:55:10PM -0800, Greg KH wrote: On Thu, Nov 27, 2014 at 03:19:44PM +1000, Peter Hutterer wrote: Currently a property in the form of FOO=bar is stored as FOO=bar, i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. --- src/udev/udevadm-hwdb.c | 4 1 file changed, 4 insertions(+) diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3ca755e..dcc6e0f 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -428,6 +428,10 @@ static int insert_data(struct trie *trie, struct udev_list *match_list, value[0] = '\0'; value++; +/* libudev requires properties to start with a space */ +while(line[0] != '\0' isblank(line[1])) Shouldn't this be while (isblank(line[0]) isblank(line[1])) ? Otherwise stuff like x yyy=111 might slip through. I pushed the patch now with the above change (and style fixes ;)). Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] udevadm hwdb: discard extra leading whitespaces in hwdb
On Thu, Nov 27, 2014 at 12:31:33PM +0100, Lennart Poettering wrote: On Thu, 27.11.14 15:19, Peter Hutterer (peter.hutte...@who-t.net) wrote: Currently a property in the form of FOO=bar is stored as FOO=bar, i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. --- src/udev/udevadm-hwdb.c | 4 1 file changed, 4 insertions(+) diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3ca755e..dcc6e0f 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -428,6 +428,10 @@ static int insert_data(struct trie *trie, struct udev_list *match_list, value[0] = '\0'; value++; +/* libudev requires properties to start with a space */ +while(line[0] != '\0' isblank(line[1])) +line++; + Please use this instead: line += strspn(line, WHITESPACE); We don't want to skip all of it, so an explicit loop seems better. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] udevadm hwdb: discard extra leading whitespaces in hwdb
On Thu, 27.11.14 15:19, Peter Hutterer (peter.hutte...@who-t.net) wrote: Currently a property in the form of FOO=bar is stored as FOO=bar, i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. --- src/udev/udevadm-hwdb.c | 4 1 file changed, 4 insertions(+) diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3ca755e..dcc6e0f 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -428,6 +428,10 @@ static int insert_data(struct trie *trie, struct udev_list *match_list, value[0] = '\0'; value++; +/* libudev requires properties to start with a space */ +while(line[0] != '\0' isblank(line[1])) +line++; + Please use this instead: line += strspn(line, WHITESPACE); Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] udevadm hwdb: discard extra leading whitespaces in hwdb
On Thu, Nov 27, 2014 at 03:19:44PM +1000, Peter Hutterer wrote: Currently a property in the form of FOO=bar is stored as FOO=bar, i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. --- src/udev/udevadm-hwdb.c | 4 1 file changed, 4 insertions(+) diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3ca755e..dcc6e0f 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -428,6 +428,10 @@ static int insert_data(struct trie *trie, struct udev_list *match_list, value[0] = '\0'; value++; +/* libudev requires properties to start with a space */ +while(line[0] != '\0' isblank(line[1])) +line++; Coding style doesn't match the rest of the file :( ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] udevadm hwdb: discard extra leading whitespaces in hwdb
On Wed, Nov 26, 2014 at 09:55:10PM -0800, Greg KH wrote: On Thu, Nov 27, 2014 at 03:19:44PM +1000, Peter Hutterer wrote: Currently a property in the form of FOO=bar is stored as FOO=bar, i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. --- src/udev/udevadm-hwdb.c | 4 1 file changed, 4 insertions(+) diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3ca755e..dcc6e0f 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -428,6 +428,10 @@ static int insert_data(struct trie *trie, struct udev_list *match_list, value[0] = '\0'; value++; +/* libudev requires properties to start with a space */ +while(line[0] != '\0' isblank(line[1])) Shouldn't this be while (isblank(line[0]) isblank(line[1])) ? Otherwise stuff like x yyy=111 might slip through. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel