env: Crash in 'env import' when using checksum and a specific size
PATCH 1/1 env: Crash in 'env import' when using checksum and a specific size
This patch adds a sanity check that avoids 'size' to overflow and crash when importing an environment that contains a checksum. Example with the wrong size that causes the crash:
=> env import -c 0x4100000 3 v1
This assumes that v1 has already been successfully exported with 'env export -c -s 0x100 0x4100000 v1'
--- cmd/nvedit.c | 5 +++++ 1 file changed, 5 insertions(+)
cmd/nvedit.c +5 -0
@@ -1171,6 +1171,11 @@ static int do_env_import(struct cmd_tbl *cmdtp, int flag,uint32_t crc;env_t *ep = (env_t *)ptr; +if (size <= offsetof(env_t , data)) { +printf ("## Error: Invalid size 0x%zX\n" , size); +return 1 ; + } + size -= offsetof(env_t , data);memcpy (&crc, &ep->crc,sizeof (crc));
Signature · 1 line
2.25.1
PATCH 1/1 env: Crash in 'env import' when using checksum and a specific size
Quoted 10 lines · Pedro Aguilar
This patch adds a sanity check that avoids 'size' to overflow and crash when importing an environment that contains a checksum. Example with the wrong size that causes the crash:
=> env import -c
0x41000003 v1This assumes that v1 has already been successfully exported with 'env export -c -s
0x1000x4100000v1'Signed-off-by Pedro Aguilar <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200914/6cde430c/attachment.sig>