mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Albert Schwarzkopf <a.schwarzkopf@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH] scripts: imx: Ignore ';' and '\n' in quotes
Date: Mon, 27 Mar 2023 10:48:27 +0200	[thread overview]
Message-ID: <20230327084827.1854478-1-a.schwarzkopf@phytec.de> (raw)

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




             reply	other threads:[~2023-03-27  8:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  8:48 Albert Schwarzkopf [this message]
2023-03-28  8:22 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230327084827.1854478-1-a.schwarzkopf@phytec.de \
    --to=a.schwarzkopf@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox