[PATCH] hush: stop parsing string at its end

Sascha Hauer s.hauer at pengutronix.de
Wed Jan 27 03:19:33 EST 2021


remove_quotes_in_str() doesn't stop parsing at the string end when
there's a single "'" in the string.
Handling quotes and double quotes is broken in many ways in hush, so
I am not exactly sure this is the right thing to do, but at least it
avoids going out of the string boundaries.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/hush.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/hush.c b/common/hush.c
index 9ced67af48..44ce4e5225 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -623,8 +623,11 @@ static void remove_quotes_in_str(char *src)
 	while (*src) {
 		if (*src == '\'') {
 			src++;
-			while (*src != '\'')
+			while (*src != '\'') {
+				if (!*src)
+					return;
 				*trg++ = *src++;
+			}
 			src++;
 			continue;
 		}
-- 
2.20.1




More information about the barebox mailing list