commands/file: Change the confusing loop stop condition.
Old condition was used to zero-out header variable on exit of the loop. This is correct but confusing. Replace with in-loop logic. Found by: Coverity Scan.
This commit is contained in:
parent
e902163e48
commit
b04c6d32ce
1 changed files with 6 additions and 5 deletions
|
@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
be at least 12 bytes and aligned on a 4-byte boundary. */
|
||||
for (header = buffer;
|
||||
((char *) header <=
|
||||
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12))
|
||||
|| (header = 0); header += step)
|
||||
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
|
||||
header += step)
|
||||
{
|
||||
if (header[0] == magic
|
||||
&& !(grub_le_to_cpu32 (header[0])
|
||||
|
@ -485,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
+ grub_le_to_cpu32 (header[2])
|
||||
+ (type == IS_MULTIBOOT2
|
||||
? grub_le_to_cpu32 (header[3]) : 0)))
|
||||
{
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (header != 0)
|
||||
ret = 1;
|
||||
grub_free (buffer);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue