"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd: ximg: handle Z_BUF_ERROR explicitly in GZIP decompression

When decompressing GZIP-compressed image parts via the `imxtract` command,
explicitly handle the `Z_BUF_ERROR` return value from `gunzip()` to provide
a clearer diagnostic. This error typically indicates that the destination
buffer is too small to hold the uncompressed data.

Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
[trini: Rework to indent the whole case with { } due to not using the
C23 extension]
Signed-off-by: Tom Rini <trini@konsulko.com>

authored by

Aristo Chen and committed by
Tom Rini
ef305cef 86acdce2

+13 -5
+13 -5
cmd/ximg.c
··· 27 27 #include <asm/byteorder.h> 28 28 #include <asm/cache.h> 29 29 #include <asm/io.h> 30 + #include <u-boot/zlib.h> 30 31 31 32 static int 32 33 do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) ··· 206 207 break; 207 208 #ifdef CONFIG_GZIP 208 209 case IH_COMP_GZIP: 209 - printf(" Uncompressing part %d ... ", part); 210 - if (gunzip((void *) dest, unc_len, 211 - (uchar *) data, &len) != 0) { 212 - puts("GUNZIP ERROR - image not loaded\n"); 213 - return 1; 210 + { 211 + int ret = 0; 212 + printf(" Uncompressing part %d ... ", part); 213 + ret = gunzip((void *)dest, unc_len, 214 + (uchar *)data, &len); 215 + if (ret == Z_BUF_ERROR) { 216 + puts("Image too large: increase CONFIG_SYS_XIMG_LEN\n"); 217 + return 1; 218 + } else if (ret != 0) { 219 + puts("GUNZIP ERROR - image not loaded\n"); 220 + return 1; 221 + } 214 222 } 215 223 break; 216 224 #endif