Attention is currently required from: Xiang Wang, Stefan Reinauer, Edward O'Callaghan. Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49741 )
Change subject: helpers.c: optimize strndup ......................................................................
Patch Set 1:
(2 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/49741/comment/79e75423_2f5715a6 PS1, Line 7: helpers.c: optimize strndup An optimization? Really?
This change fixes potential undefined behavior. So, I'd rewrite the commit message as follows:
helpers.c: Fix undefined behavior in strndup()
Using strlen() or strdup() inside strndup() is problematic: if the input string is not null-terminated, these functions can read past the end of the buffer, which triggers undefined behavior. Rewrite the function to never read past the provided `maxlen` bound.
https://review.coreboot.org/c/flashrom/+/49741/comment/b1860f77_35657b2d PS1, Line 10: has no feedback for a long time This is just one of the possible outcomes of undefined behavior. It could also result in a segmentation fault, or start reading registers from a MMIO window, or something else I didn't think of.