mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
In certain situations util_file_read_fd_buf() might return a larger buffer than printable characters were read (e.g. a file was padded with zeros). This can lead to util_file_read_fd() returning NULL with a freed buffer even though a certain amount of printable characters were read. This behaviour causes a regression introduced with commit9efd1df31d("ipl_tools: Refactor read helper using util_file_read_text_file()") in ipl_tools were the scp_data sysfs attribute is padded with 0 to fit an 8 byte alignment required by the architecture. Fix this by comparing the size read with the actual string length and use the smaller value for further processing. Fixes:9efd1df31d("ipl_tools: Refactor read helper using util_file_read_text_file()") Tested-by: Jan Polensky <japo@linux.ibm.com> Reviewed-by: Jan Polensky <japo@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>