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

Sascha Hauer sha at pengutronix.de
Tue Mar 28 01:22:16 PDT 2023


On Mon, Mar 27, 2023 at 10:48:27AM +0200, Albert Schwarzkopf wrote:
> 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(-)

Applied, thanks

Sascha

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

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



More information about the barebox mailing list