[EXT] [PATCH 1/1] mvebu: fix end-of-array check
Kostya Porotchkin
kostap at marvell.com
Sun Dec 4 08:17:30 CET 2022
________________________________
From: Derek LaHousse <derek at seaofdirac.org>
Sent: Wednesday, November 30, 2022 20:33
To: u-boot at lists.denx.de <u-boot at lists.denx.de>
Cc: sr at denx.de <sr at denx.de>; Kostya Porotchkin <kostap at marvell.com>; pali at kernel.org <pali at 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 at 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 at marvell.com>
--
2.30.2
More information about the U-Boot
mailing list