From 376c8d5bbb7e31987e363ee4c481ae8ff5015a77 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 28 Aug 2014 08:22:42 -0700 Subject: [PATCH] Check S-record with 0 size * srec.c (srec_scan): Return error for 0 size. --- bfd/ChangeLog | 4 ++++ bfd/srec.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bba079f481f..6484c91df83 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2014-08-28 H.J. Lu + + * srec.c (srec_scan): Return error for 0 size. + 2014-08-27 H.J. Lu PR ld/17306 diff --git a/bfd/srec.c b/bfd/srec.c index f11e74a0295..d979bf55564 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -486,7 +486,8 @@ srec_scan (bfd *abfd) bufsize = bytes * 2; } - if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2) + if (bytes == 0 + || bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2) goto error_return; /* Ignore the checksum byte. */ -- 2.30.2