提交 c3b115f4 编写于 作者: A Alexander Dahl 提交者: Tom Rini

tools: mkenvimage: Fix possible segfault on stdin input

The size of 'filebuf' was not increased as more and more bytes are read
from stdin, but 'filebuf' was always reallocated to the same fix size.
This works as long as only less bytes than the initial buffer size come
in, for more input this will segfault. (It actually does, I tested
that.) So for each loop cycle the buffer size has to be increased by the
number of bytes we want to read.
Signed-off-by: NAlexander Dahl <ada@thorsis.com>
上级 3559028c
......@@ -162,7 +162,7 @@ int main(int argc, char **argv)
txt_fd = STDIN_FILENO;
do {
filebuf = realloc(filebuf, readlen);
filebuf = realloc(filebuf, filesize + readlen);
if (!filebuf) {
fprintf(stderr, "Can't realloc memory for the input file buffer\n");
return EXIT_FAILURE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册