From 5fb5ebf71bcc54c6a45d421b7b52f4fb20f7b185 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Mon, 21 Apr 2025 10:58:23 +0200 Subject: [PATCH] chore(fs_section): add more info to section header error messages --- src/internal/fs_section.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/internal/fs_section.cpp b/src/internal/fs_section.cpp index 796ca058..da0afc2f 100644 --- a/src/internal/fs_section.cpp +++ b/src/internal/fs_section.cpp @@ -47,7 +47,9 @@ template void read_section_header_common(T& header, size_t& start, mmif const& mm, size_t offset) { if (offset + sizeof(T) > mm.size()) { - DWARFS_THROW(runtime_error, "truncated section header"); + DWARFS_THROW(runtime_error, + fmt::format("truncated section header: {} + {} > {}", offset, + sizeof(T), mm.size())); } ::memcpy(&header, mm.as(offset), sizeof(T)); @@ -57,11 +59,13 @@ void read_section_header_common(T& header, size_t& start, mmif const& mm, auto end = offset + header.length; if (end < offset) { - DWARFS_THROW(runtime_error, "offset/length overflow"); + DWARFS_THROW(runtime_error, + fmt::format("offset/length overflow: {} < {}", end, offset)); } if (end > mm.size()) { - DWARFS_THROW(runtime_error, "truncated section data"); + DWARFS_THROW(runtime_error, fmt::format("truncated section data: {} > {}", + end, mm.size())); } start = offset;