scripts: imx: Ignore ';' and '\n' in quotes
PATCH 1/1 scripts: imx: Ignore ';' and '\n' in quotes
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 <[email protected]>
--- scripts/imx/imx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/imx/imx.c +4 -2
@@ -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; }
Signature · 1 line
2.40.0
Sascha Hauer
AppliedQuoted 10 lines · Albert Schwarzkopf
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 <[email protected]>--- scripts/imx/imx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
Quoted 30 lines
scripts/imx/imx.c +4
-2@@ -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; }Signature · 1 line
2.40.0
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |