Skip to content

Commit 7a100dc

Browse files
committed
hwdb: emit warning when matches are specified at the very end of file
This is also an error, but it wasn't caught. [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:26] Property expected, ignoring record with no properties
1 parent a6a2f01 commit 7a100dc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/hwdb/hwdb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
554554
break;
555555
}
556556

557-
/* another match */
558557
if (line[0] != ' ') {
558+
/* another match */
559559
match = strdup(line);
560560
if (!match)
561561
return -ENOMEM;
@@ -573,8 +573,8 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
573573
break;
574574

575575
case HW_DATA:
576-
/* end of record */
577576
if (len == 0) {
577+
/* end of record */
578578
state = HW_NONE;
579579
strv_clear(match_list);
580580
break;
@@ -593,6 +593,10 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
593593
};
594594
}
595595

596+
if (state == HW_MATCH)
597+
log_syntax(NULL, LOG_WARNING, filename, line_number, EINVAL,
598+
"Property expected, ignoring record with no properties");
599+
596600
return 0;
597601
}
598602

0 commit comments

Comments
 (0)