diff mbox series

[U-Boot,V2,2/4] tools: imx8image: fix coverity CID 184234

Message ID 20181105100112.21490-2-peng.fan@nxp.com
State Accepted
Delegated to: Stefano Babic
Headers show
Series [U-Boot,V2,1/4] tools: imx8image: check lseek return value | expand

Commit Message

Peng Fan Nov. 5, 2018, 9:53 a.m. UTC
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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/imx8image.c b/tools/imx8image.c
index 03debe547e..019b875773 100644
--- a/tools/imx8image.c
+++ b/tools/imx8image.c
@@ -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);