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 <pjones@redhat.com>
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;
}