diff mbox series

[v4l-utils] keytable: keymap without protocol is invalid

Message ID 20200121165212.441-1-sean@mess.org (mailing list archive)
State New, archived
Headers show
Series [v4l-utils] keytable: keymap without protocol is invalid | expand

Commit Message

Sean Young Jan. 21, 2020, 4:52 p.m. UTC
Without a protocol, keymap cannot be loaded and causes a segfault.

Reported-by: Camden Lindsay <camden.lindsay+kernel@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
---
 utils/common/keymap.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/utils/common/keymap.c b/utils/common/keymap.c
index d06deb59..6ca33745 100644
--- a/utils/common/keymap.c
+++ b/utils/common/keymap.c
@@ -169,6 +169,11 @@  static error_t parse_plain_keymap(char *fname, struct keymap **keymap, bool verb
 	}
 	fclose(fin);
 
+	if (!map->protocol) {
+		fprintf(stderr, _("Missing protocol in %s\n"), fname);
+		return EINVAL;
+	}
+
 	*keymap = map;
 
 	return 0;