aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@mailbox.org>2023-03-02 04:08:21 +0100
committerSimon Glass <sjg@chromium.org>2023-03-08 11:40:57 -0800
commit22cbd654d33f60b7d7941c4ba2484bcc610f4e50 (patch)
tree7237aed92563068eeae9f36623073040ac590f66 /cmd
parent3300a6027772105ed4f4dd34001bd532ee21de8c (diff)
downloadu-boot-22cbd654d33f60b7d7941c4ba2484bcc610f4e50.zip
u-boot-22cbd654d33f60b7d7941c4ba2484bcc610f4e50.tar.gz
u-boot-22cbd654d33f60b7d7941c4ba2484bcc610f4e50.tar.bz2
cmd: fdt: Handle 64bit pointers in fdt get addr
The command assumed 32bit pointers so far, with 64bit pointer the command would overwrite a piece of stack. Fix it by extending the array size to cater for 64bit pointer, and use snprintf() to avoid writing past the end of the array ever again. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/fdt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 279dad9..bc19303 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -466,9 +466,9 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
return ret;
} else if (subcmd[0] == 'a') {
/* Get address */
- char buf[11];
+ char buf[19];
- sprintf(buf, "0x%p", nodep);
+ snprintf(buf, sizeof(buf), "0x%p", nodep);
env_set(var, buf);
} else if (subcmd[0] == 's') {
/* Get size */