tekhex: Uninitialised read

Message ID 20200331062623.GY4583@bubble.grove.modra.org
State New
Headers show
Series
  • tekhex: Uninitialised read
Related show

Commit Message

H.J. Lu via Binutils March 31, 2020, 6:26 a.m.
* tekhex.c (pass_over): Check is_eof before reading buffer.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index c2834b32d0..0001457c74 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -525,7 +525,7 @@  pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *, char *))
 
       /* Find first '%'.  */
       is_eof = (bfd_boolean) (bfd_bread (src, (bfd_size_type) 1, abfd) != 1);
-      while (*src != '%' && !is_eof)
+      while (!is_eof && *src != '%')
 	is_eof = (bfd_boolean) (bfd_bread (src, (bfd_size_type) 1, abfd) != 1);
 
       if (is_eof)