[PATCH] scripts: imx: Ignore ';' and '\n' in quotes
Albert Schwarzkopf
a.schwarzkopf at phytec.de
Mon Mar 27 01:48:27 PDT 2023
The current behaviour treats semicolons the same as end of line.
This breaks when they are found inside quoted strings, as is the
case for PKCS#11 URIs for example.
Ignore newlines and semicolons in quotes when parsing commands.
Signed-off-by: Albert Schwarzkopf <a.schwarzkopf at phytec.de>
---
scripts/imx/imx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 87560ad27d..fac0556308 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -675,6 +675,7 @@ static char *readcmd(struct config_data *data, FILE *f)
static char *buf;
char *str;
ssize_t ret;
+ int inquotes = 0;
if (!buf) {
buf = malloc(4096);
@@ -689,8 +690,9 @@ static char *readcmd(struct config_data *data, FILE *f)
ret = fread(str, 1, 1, f);
if (!ret)
return strlen(buf) ? buf : NULL;
-
- if (*str == '\n' || *str == ';') {
+ if (*str == '"') {
+ inquotes = !inquotes;
+ } else if ((*str == '\n' || *str == ';') && !inquotes) {
*str = 0;
return buf;
}
--
2.40.0
More information about the barebox
mailing list