(backport) Fix format-truncation compile failure by typecasting USB IDs (#8250)
authorPatrick Uiterwijk <patrick@puiterwijk.org>
Thu, 22 Feb 2018 18:41:30 +0000 (19:41 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 12 Feb 2024 15:37:44 +0000 (16:37 +0100)
commit4acc4d9083c4c16078fa2c8c679103bb60d6c2a7
tree423a451017c9102b29057e591064e944c520a037
parent13304271e4562d4064d08cd8d49a16b485229ed7
(backport) Fix format-truncation compile failure by typecasting USB IDs (#8250)

This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bit int, and
uses that for parsing USB device and vendor IDs.

This fixes a compile error with gcc-8 because while we know that USB IDs are 2 bytes,
the compiler does not know that.

../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output may be
truncated writing between 4 and 8 bytes into a region of size between 2 and 6
[-Werror=format-truncation=]

Change-Id: I40b2eb8b424c57ba430b217ebead2fc5d67bbb14
Signed-off-by: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
src/basic/parse-util.c
src/basic/parse-util.h
src/test/test-parse-util.c
src/udev/udev-builtin-hwdb.c