]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: samsung: fix set_board_info() board_name buffer overflow
authorNgo Luong Thanh Tra <ngotra27101996@gmail.com>
Sat, 28 Mar 2026 06:01:31 +0000 (13:01 +0700)
committerTom Rini <trini@konsulko.com>
Mon, 13 Apr 2026 23:42:34 +0000 (17:42 -0600)
Replace unbounded sprintf() with snprintf() using sizeof(info) as
the bound when constructing the board_name string from bdname and
bdtype. The previous call had no size limit and could overflow the
64-byte stack buffer if the concatenated string exceeded 63 bytes.

Fixes: c9c36bf56e4c ("samsung: misc: use board specific functions to set env board info")
Signed-off-by: Ngo Luong Thanh Tra <S4210155@student.rmit.edu.au>
To: u-boot@lists.denx.de

board/samsung/common/misc.c

index 85e564f27ee5c79a0e4d2a36fe2069c2cb06f258..a6ba41d2805e5d9e808e5f82a1839df06589bc6a 100644 (file)
@@ -101,7 +101,7 @@ void set_board_info(void)
        if (!bdtype)
                bdtype = "";
 
-       sprintf(info, "%s%s", bdname, bdtype);
+       snprintf(info, sizeof(info), "%s%s", bdname, bdtype);
        env_set("board_name", info);
 #endif
        snprintf(info, ARRAY_SIZE(info),  "%s%x-%s%s.dtb",