summaryrefslogtreecommitdiff
path: root/src/hwdb
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-01 11:32:41 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-01 11:57:08 -0500
commita6a2f018bec9087427ba202691db7b663cce932c (patch)
treebdd00b1b14059559f1123883e9a02c54fb805e39 /src/hwdb
parent49141e0cd1a56e5f97e81e13a6d7be85138c134c (diff)
downloadsystemd-a6a2f018bec9087427ba202691db7b663cce932c.tar.gz
hwdb: fix detection of assignments with no key
The code was trying to detect an empty key, but property lines always start with a space, so the condition was wrong. Now: [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:14] Empty key in " =NO_NAME", ignoring [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:15] Empty value in " NO_VALUE=", ignoring
Diffstat (limited to 'src/hwdb')
-rw-r--r--src/hwdb/hwdb.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c
index 6d4a03bedb..d2fe75fc79 100644
--- a/src/hwdb/hwdb.c
+++ b/src/hwdb/hwdb.c
@@ -456,6 +456,8 @@ static int insert_data(struct trie *trie, char **match_list, char *line,
const char *filename, uint16_t file_priority, uint32_t line_number) {
char *value, **entry;
+ assert(line[0] == ' ');
+
value = strchr(line, '=');
if (!value)
return log_syntax(NULL, LOG_WARNING, filename, line_number, EINVAL,
@@ -464,13 +466,15 @@ static int insert_data(struct trie *trie, char **match_list, char *line,
value[0] = '\0';
value++;
- /* libudev requires properties to start with a space */
+ /* Replace multiple leading spaces by a single space */
while (isblank(line[0]) && isblank(line[1]))
line++;
- if (line[0] == '\0' || value[0] == '\0')
+ if (isempty(line + 1) || isempty(value))
return log_syntax(NULL, LOG_WARNING, filename, line_number, EINVAL,
- "Empty %s in \"%s\", ignoring", line[0] == '\0' ? "key" : "value", line);
+ "Empty %s in \"%s=%s\", ignoring",
+ isempty(line + 1) ? "key" : "value",
+ line, value);
STRV_FOREACH(entry, match_list)
trie_insert(trie, trie->root, *entry, line, value, filename, file_priority, line_number);