U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mvebu: fix end-of-array check
@ 2022-11-30 18:33 Derek LaHousse
  2022-12-04  7:17 ` [EXT] " Kostya Porotchkin
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Derek LaHousse @ 2022-11-30 18:33 UTC (permalink / raw)
  To: u-boot; +Cc: sr, kostap, pali

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
-- 
2.30.2




^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-12-07  7:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-30 18:33 [PATCH 1/1] mvebu: fix end-of-array check Derek LaHousse
2022-12-04  7:17 ` [EXT] " Kostya Porotchkin
2022-12-04 10:39 ` Pali Rohár
2022-12-05 11:42   ` Stefan Roese
2022-12-05 18:18     ` Pali Rohár
2022-12-06  6:10       ` Stefan Roese
2022-12-06 19:56         ` Pali Rohár
2022-12-07  7:14           ` Stefan Roese
2022-12-04 21:16 ` Simon Glass
2022-12-04 21:51   ` Pali Rohár
2022-12-05 16:11     ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox