From 7461d47cddf1cb27b1aeb646e1cdc9f7ecc6219a Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 13 Mar 2018 17:10:56 -0400 Subject: [PATCH] Work around -Werror=stringop-overflow= being daft. With: len = strlen(foo + offset) + 1; buf = calloc(1, len); if (!buf) err(1, "out of memory"); strncpy(buf, foo+offset, len); -Wstringop-overflow complains: efivar.c:169:2: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy(name_buf, guid_name + name_pos, name_len); ^ efivar.c:163:13: note: length computed here name_len = strlen(guid_name + name_pos) + 1; ^ lto1: all warnings being treated as errors Which... Duh, so was the allocation it's writing into. So what? Signed-off-by: Peter Jones --- src/efivar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/efivar.c b/src/efivar.c index 9f8ef6d..206770d 100644 --- a/src/efivar.c +++ b/src/efivar.c @@ -166,7 +166,7 @@ bad_name: fprintf(stderr, "efivar: %m\n"); exit(1); } - strncpy(name_buf, guid_name + name_pos, name_len); + strcpy(name_buf, guid_name + name_pos); *name = name_buf; } -- 2.11.0