X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fmkenvimage.c;h=75967d0c2d59667da31ada29bc3d7abb3e3b5acc;hb=3aba3fd65490eff5305160e92937dc5592ab9bfb;hp=8eee72e2572e321bbcf70d516d884708724f7fa4;hpb=1d2f74690cace803844bce198a6d5fa1b6cd11f9;p=u-boot diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 8eee72e257..75967d0c2d 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2011 Free Electrons * David Wagner @@ -5,8 +6,6 @@ * Inspired from envcrc.c: * (C) Copyright 2001 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -162,13 +161,13 @@ 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; } readbytes = read(txt_fd, filebuf + filesize, readlen); - if (errno) { + if (readbytes < 0) { fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); return EXIT_FAILURE;