Possible segfault in file2strvec introduced by latest CVE fix
'rbuf' used before allocated. Revealed by static analysis References: commit 36e066df52eedf147a51e4cf3a86fd13748d6f79 Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
16bd4cd5aa
commit
7febddabd8
@ -744,7 +744,8 @@ static char** file2strvec(const char* directory, const char* what) {
|
|||||||
#undef ARG_LEN
|
#undef ARG_LEN
|
||||||
if (end_of_file &&
|
if (end_of_file &&
|
||||||
((n > 0 && buf[n-1] != '\0') || /* last read char not null */
|
((n > 0 && buf[n-1] != '\0') || /* last read char not null */
|
||||||
(n <= 0 && rbuf[tot-1] != '\0'))) /* last read char not null */
|
(n <= 0 && rbuf && rbuf[tot-1] != '\0'))) /* last read char not null */
|
||||||
|
|
||||||
buf[n++] = '\0'; /* so append null-terminator */
|
buf[n++] = '\0'; /* so append null-terminator */
|
||||||
|
|
||||||
if (n <= 0) break; /* unneeded (end_of_file = 1) but avoid realloc */
|
if (n <= 0) break; /* unneeded (end_of_file = 1) but avoid realloc */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user