
________________________________ From: Derek LaHousse derek@seaofdirac.org Sent: Wednesday, November 30, 2022 20:33 To: u-boot@lists.denx.de u-boot@lists.denx.de Cc: sr@denx.de sr@denx.de; Kostya Porotchkin kostap@marvell.com; pali@kernel.org pali@kernel.org Subject: [EXT] [PATCH 1/1] mvebu: fix end-of-array check
External Email
---------------------------------------------------------------------- Properly seek the end of default_environment variables.
The current algorithm overwrites from the second variable. This replacement finds the end of the array of strings.
Stomped variables include "board", "soc", "loadaddr". These can be seen on a "env default -a" after patch, but they are not seen with a version before the patch.
Signed-off-by: Derek LaHousse derek@seaofdirac.org --- board/Marvell/mvebu_armada-37xx/board.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index c6ecc323bb..ac29ac5b95 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -100,8 +100,11 @@ int board_late_init(void) return 0;
/* Find free buffer in default_environment[] for new variables */ - while (*ptr != '\0' && *(ptr+1) != '\0') ptr++; - ptr += 2; + if (*ptr != '\0') { // Defending against empty default env + while ((i = strlen(ptr)) != 0) { + ptr += i + 1; + } + }
/* * Ensure that 'env default -a' does not erase permanent MAC addresses
Acked-by: Konstantin Porotchkin kostap@marvell.com
-- 2.30.2