[PATCH v1 0/1] readelf: invalid error message triggered when last tag is an empty string

Matthieu Longo matthieu.longo@arm.com
Wed Jun 18 10:27:51 GMT 2025


** Disclaimer: **
This issue cannot occur with Object Attributes v1 (OAv1) because a value of '\0' (empty string) for a tag with a string value is considered as the default value for the attribute, and consequently is eliminated from the output object during the serialization.

## Content

In the context of OAv2 [1], an empty string is a valid value for a string attribute tag, and can be saved as a tag might not have a default value.
In the case where this tag is last in the object attributes section, the current check incorrectly detects an overflow, and prints out an error message for a corrupted string tag.

This patch fixes the detection of the overflow so that it now accept an empty string in the last tag of the object attributes section.

## Testing

Today, no test can be added since the bug cannot be triggered in the context of OAv1. This fix was tested in the context of OAv2's patch series [1] that will add tests to cover this specific use case.
Tested on arm-none-eabi on master, and aarch64-elf-none in context of [1], and no regression found.

## Reference

[1]: https://inbox.sourceware.org/binutils/20250509151319.88725-1-matthieu.longo@arm.com/


Matthieu Longo (1):
  readelf: invalid error message triggered when last tag is an empty string

 binutils/readelf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.50.0



More information about the Binutils mailing list