"Das U-Boot" Source Tree
0
fork

Configure Feed

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

cmd: unzip: Use map_sysmem() with buffers in the gzwrite command

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

Convert 'addr' variable to unsigned long, as that is the return type of
hextoul() and address parameter type of map_sysmem().

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

authored by

Marek Vasut and committed by
Tom Rini
f2c704c0 02ffe4a0

+8 -3
+8 -3
cmd/unzip.c
··· 50 50 { 51 51 struct blk_desc *bdev; 52 52 int ret; 53 - unsigned char *addr; 53 + unsigned long addr; 54 54 unsigned long length; 55 55 unsigned long writebuf = 1<<20; 56 56 off_t startoffs = 0; 57 57 size_t szexpected = 0; 58 + void *addrp; 58 59 59 60 if (argc < 5) 60 61 return CMD_RET_USAGE; ··· 62 63 if (ret < 0) 63 64 return CMD_RET_FAILURE; 64 65 65 - addr = (unsigned char *)hextoul(argv[3], NULL); 66 + addr = hextoul(argv[3], NULL); 66 67 length = hextoul(argv[4], NULL); 67 68 68 69 if (5 < argc) { ··· 75 76 } 76 77 } 77 78 78 - ret = gzwrite(addr, length, bdev, writebuf, startoffs, szexpected); 79 + addrp = map_sysmem(addr, length); 80 + 81 + ret = gzwrite(addrp, length, bdev, writebuf, startoffs, szexpected); 82 + 83 + unmap_sysmem(addrp); 79 84 80 85 return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS; 81 86 }