diff mbox series

bootloader: fix setting GRUB variable

Message ID 1519030756-17333-1-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series bootloader: fix setting GRUB variable | expand

Commit Message

Stefano Babic Feb. 19, 2018, 8:59 a.m. UTC
Due to a bug while variables are parsed, a long string for the value
of a variable is truncated.
The following works:

{
	name = "var1";
	value = "val1";
}

but it does not work in this case:

{
	name = "var1";
	value = "val1 val2 val3 val4";
}

and the result is just var1=val1

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 bootloader/grub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Storm, Christian Feb. 19, 2018, 9:02 a.m. UTC | #1
Hi Stefano,

> Due to a bug while variables are parsed, a long string for the value
> of a variable is truncated.
> The following works:
> 
> {
> 	name = "var1";
> 	value = "val1";
> }
> 
> but it does not work in this case:
> 
> {
> 	name = "var1";
> 	value = "val1 val2 val3 val4";
> }
> 
> and the result is just var1=val1
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> ---
>  bootloader/grub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/bootloader/grub.c b/bootloader/grub.c
> index dc35718..4c9b0b8 100644
> --- a/bootloader/grub.c
> +++ b/bootloader/grub.c
> @@ -123,7 +123,7 @@ static int grubenv_parse_script(struct grubenv_t *grubenv, const char *script)
>  	 */
>  	while ((getline(&line, &len, fp)) != -1) {
>  		key = strtok(line, " \t\n");
> -		value = strtok(NULL, " \t\n");
> +		value = strtok(NULL, "\t\n");
>  		if (value != NULL && key != NULL) {
>  			ret = dict_set_value(&grubenv->vars, key, value);
>  			if (ret) {
> -- 
> 2.7.4
> 


Acked-by: Christian Storm <christian.storm@siemens.com>


Besten Gruß,
   Christian
diff mbox series

Patch

diff --git a/bootloader/grub.c b/bootloader/grub.c
index dc35718..4c9b0b8 100644
--- a/bootloader/grub.c
+++ b/bootloader/grub.c
@@ -123,7 +123,7 @@  static int grubenv_parse_script(struct grubenv_t *grubenv, const char *script)
 	 */
 	while ((getline(&line, &len, fp)) != -1) {
 		key = strtok(line, " \t\n");
-		value = strtok(NULL, " \t\n");
+		value = strtok(NULL, "\t\n");
 		if (value != NULL && key != NULL) {
 			ret = dict_set_value(&grubenv->vars, key, value);
 			if (ret) {