summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/mkenvimage.c4
-rw-r--r--tools/mkimage.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index 8eee72e2572..8cd9ffa1c6a 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -162,13 +162,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;
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 4e561820e77..32e07be94af 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -301,6 +301,8 @@ static void process_args(int argc, char **argv)
else if (!params.datafile)
usage("Missing data file for auto-FIT (use -d)");
} else if (type != IH_TYPE_INVALID) {
+ if (type == IH_TYPE_SCRIPT && !params.datafile)
+ usage("Missing data file for script (use -d)");
params.type = type;
}