Commit 2127613
committed
Realloc() needs one more byte for sprintf()
In generate_sbat_var_defs.c, realloc() should allocate one more byte for
the end of string '\0' when running sprintf() later.
Suppose we use fgets() to get line="abc\n", so strlen(line)=4 bytes.
realloc(...,strlen(line),1) will allocate 5 bytes which is not capable to
save line(3 bytes),'\' and 'n'(2 bytes) pluses extra '\0' byte totally 6 bytes
when running sprintf(.....,"%s\\n", line) later on.
where '\n' of line has been removed in line[strlen(line) - 1] = 0;
Signed-off-by: Dennis Tseng <dennis.tseng@suse.com>1 parent d44405e commit 2127613
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
0 commit comments