diff --git a/scripts/zynq_mkimage.c b/scripts/zynq_mkimage.c index 0a1c069..a211b79 100644 --- a/scripts/zynq_mkimage.c +++ b/scripts/zynq_mkimage.c @@ -241,7 +241,7 @@ char *buf; const char *infile = NULL, *outfile = NULL, *cfgfile = NULL; struct stat st; - int opt; + int opt, ret; prgname = argv[0]; @@ -309,7 +309,12 @@ exit(EXIT_FAILURE); } - fread(buf + IMAGE_OFFSET, sizeof(char), st.st_size, ifile); + ret = fread(buf + IMAGE_OFFSET, sizeof(char), st.st_size, ifile); + + if(ret != st.st_size) { + fprintf(stderr, "Error while reading %s\n", infile); + exit(EXIT_FAILURE); + } add_header(buf, st.st_size);