rescue_parser: restructure code to avoid Coverity false positive
If line contains single word, line and argv[0] are aliases, so no NULL dereference is possible, but Coverity does not know it. Change code to avoid ambiguity and also remove redundant call to grub_strchr. CID: 86725
This commit is contained in:
parent
725548a285
commit
bd60f5a207
1 changed files with 10 additions and 5 deletions
|
@ -43,14 +43,18 @@ grub_rescue_parse_line (char *line,
|
||||||
|
|
||||||
/* In case of an assignment set the environment accordingly
|
/* In case of an assignment set the environment accordingly
|
||||||
instead of calling a function. */
|
instead of calling a function. */
|
||||||
if (n == 1 && grub_strchr (line, '='))
|
if (n == 1)
|
||||||
{
|
{
|
||||||
char *val = grub_strchr (args[0], '=');
|
char *val = grub_strchr (args[0], '=');
|
||||||
|
|
||||||
|
if (val)
|
||||||
|
{
|
||||||
val[0] = 0;
|
val[0] = 0;
|
||||||
grub_env_set (args[0], val + 1);
|
grub_env_set (args[0], val + 1);
|
||||||
val[0] = '=';
|
val[0] = '=';
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the command name. */
|
/* Get the command name. */
|
||||||
name = args[0];
|
name = args[0];
|
||||||
|
@ -72,6 +76,7 @@ grub_rescue_parse_line (char *line,
|
||||||
}
|
}
|
||||||
|
|
||||||
quit:
|
quit:
|
||||||
|
/* Arguments are returned in single memory chunk separated by zeroes */
|
||||||
grub_free (args[0]);
|
grub_free (args[0]);
|
||||||
grub_free (args);
|
grub_free (args);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue