From b5f376d11d9f9e25be32920705bd5ee54684ca36 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 27 Jul 2019 18:55:01 +0100 Subject: lscpu: prefer memcpy() to manual pointer arithmetic With pointer arithmetic clang address sanitizer gives following error this change addresses. Notice the following happens only when running as root. sys-utils/lscpu-dmi.c:83:14: runtime error: load of misaligned address 0x55a1d62f3d1d for type 'const uint16_t' (aka 'const unsigned short'), which requires 2 byte alignment Signed-off-by: Sami Kerola --- sys-utils/lscpu-dmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c index 29bd2e4fc..82d8ed443 100644 --- a/sys-utils/lscpu-dmi.c +++ b/sys-utils/lscpu-dmi.c @@ -80,7 +80,7 @@ static void to_dmi_header(struct dmi_header *h, uint8_t *data) { h->type = data[0]; h->length = data[1]; - h->handle = WORD(data + 2); + memcpy(&h->handle, data + 2, sizeof(h->handle)); h->data = data; } -- cgit v1.2.3-55-g7522