diff options
author | Marek Vasut <marek.vasut+renesas@mailbox.org> | 2023-03-02 04:08:21 +0100 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-03-09 08:50:47 -0800 |
commit | 98d114e75c888ed7a8313a14e778f45d388199c4 (patch) | |
tree | ec9c0dcb1397e1887d7c0f7b8ea45ddf2dab63d7 | |
parent | 068b7d9ed379e5376550709bd3c238d2777a3cfe (diff) | |
download | u-boot-98d114e75c888ed7a8313a14e778f45d388199c4.zip u-boot-98d114e75c888ed7a8313a14e778f45d388199c4.tar.gz u-boot-98d114e75c888ed7a8313a14e778f45d388199c4.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>
-rw-r--r-- | cmd/fdt.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 */ |