[PATCH] scripts: imx: Ignore ';' and '\n' in quotes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux