X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fzynqimage.c;h=d3f418b0612b311b0537dddce8769c6e07b046a4;hb=94905e1db8d8d42c4f39f14dbee2f9788390db5e;hp=b47132b02a60f4441bcf1205213da6a08324163f;hpb=b591730c357fd9347c4134ac2883ae039b79915c;p=u-boot diff --git a/tools/zynqimage.c b/tools/zynqimage.c index b47132b02a..d3f418b061 100644 --- a/tools/zynqimage.c +++ b/tools/zynqimage.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2015 Nathan Rossi * - * SPDX-License-Identifier: GPL-2.0+ - * * The following Boot Header format/structures and values are defined in the * following documents: * * Xilinx Zynq-7000 Technical Reference Manual (Section 6.3) @@ -147,6 +146,12 @@ static int zynqimage_verify_header(unsigned char *ptr, int image_size, if (image_size < sizeof(struct zynq_header)) return -1; + if (zynqhdr->__reserved1 != 0) + return -1; + + if (zynqhdr->__reserved2 != 0) + return -1; + if (zynqhdr->width_detection != HEADER_WIDTHDETECTION) return -1; if (zynqhdr->image_identifier != HEADER_IMAGEIDENTIFIER) @@ -239,11 +244,15 @@ static void zynqimage_parse_initparams(struct zynq_header *zynqhdr, } err = fstat(fileno(fp), &path_stat); - if (err) + if (err) { + fclose(fp); return; + } - if (!S_ISREG(path_stat.st_mode)) + if (!S_ISREG(path_stat.st_mode)) { + fclose(fp); return; + } do { r = fscanf(fp, "%x %x", ®init.address, ®init.data);