"Das U-Boot" Source Tree
0
fork

Configure Feed

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

cmd: zip: Use map_sysmem() with buffers in the zip command

The current implementation casts an address to a pointer. Make it more
sandbox-friendly by using map_sysmem().

Use symbolic return value for the command while updating
the return value handling.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

authored by

Marek Vasut and committed by
Tom Rini
3a76ba66 f2c704c0

+14 -3
+14 -3
cmd/zip.c
··· 7 7 #include <command.h> 8 8 #include <env.h> 9 9 #include <gzip.h> 10 + #include <mapmem.h> 10 11 #include <vsprintf.h> 11 12 12 13 static int do_zip(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) 13 14 { 14 15 unsigned long src, dst; 15 16 unsigned long src_len, dst_len = ~0UL; 17 + void *srcp, *dstp; 18 + int ret; 16 19 17 20 switch (argc) { 18 21 case 5: ··· 27 30 return cmd_usage(cmdtp); 28 31 } 29 32 30 - if (gzip((void *) dst, &dst_len, (void *) src, src_len) != 0) 31 - return 1; 33 + srcp = map_sysmem(src, src_len); 34 + dstp = map_sysmem(dst, dst_len); 35 + 36 + ret = gzip(dstp, &dst_len, srcp, src_len); 37 + 38 + unmap_sysmem(dstp); 39 + unmap_sysmem(srcp); 40 + 41 + if (ret) 42 + return CMD_RET_FAILURE; 32 43 33 44 printf("Compressed size: %lu = 0x%lX\n", dst_len, dst_len); 34 45 env_set_hex("filesize", dst_len); 35 46 36 - return 0; 47 + return CMD_RET_SUCCESS; 37 48 } 38 49 39 50 U_BOOT_CMD(