Skip to content

Commit

Permalink
Fix a bug where EOF resulted in infinite loop.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 706806310
Change-Id: I15f7d8cb57c0dfb7f6bb35b623347e386af032cd
  • Loading branch information
Abseil Team authored and copybara-github committed Dec 16, 2024
1 parent 82d40e6 commit 03c34a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions absl/debugging/symbolize_elf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,9 @@ static ABSL_ATTRIBUTE_NOINLINE bool GetSectionHeaderByType(
(buf_bytes > num_bytes_left) ? num_bytes_left : buf_bytes;
const off_t offset = sh_offset + static_cast<off_t>(i * sizeof(buf[0]));
const ssize_t len = file->ReadFromOffset(buf, num_bytes_to_read, offset);
if (len < 0) {
ABSL_RAW_LOG(
WARNING,
"Reading %zu bytes from offset %ju returned %zd which is negative.",
num_bytes_to_read, static_cast<intmax_t>(offset), len);
if (len <= 0) {
ABSL_RAW_LOG(WARNING, "Reading %zu bytes from offset %ju returned %zd.",
num_bytes_to_read, static_cast<intmax_t>(offset), len);
return false;
}
if (static_cast<size_t>(len) % sizeof(buf[0]) != 0) {
Expand Down

0 comments on commit 03c34a9

Please sign in to comment.