tools: imx8image: fix coverity CID 184234
authorPeng Fan <peng.fan@nxp.com>
Mon, 5 Nov 2018 09:53:25 +0000 (09:53 +0000)
committerStefano Babic <sbabic@denx.de>
Tue, 6 Nov 2018 10:23:45 +0000 (11:23 +0100)
Fix:
CID 184234:    (TAINTED_SCALAR)
Using tainted variable "header.num_images - 1" as an index into an array "header.img".

Reported-by: Coverity
Signed-off-by: Peng Fan <peng.fan@nxp.com>
tools/imx8image.c

index 03debe547e62d1aa7172630598bca32df7583648..019b875773be99e4183c125182005bde551e66ec 100644 (file)
@@ -666,8 +666,10 @@ static int get_container_image_start_pos(image_t *image_stack, uint32_t align)
                        }
 
                        ret = fread(&header, sizeof(header), 1, fd);
-                       if (ret != 1)
+                       if (ret != 1) {
                                printf("Failure Read header %d\n", ret);
+                               exit(EXIT_FAILURE);
+                       }
 
                        fclose(fd);