[v2] sprof: check pread size and offset for overflow
DJ Delorie
dj@redhat.com
Fri Oct 17 18:39:02 GMT 2025
Paul Eggert <eggert@cs.ucla.edu> writes:
> There is no need to check separately that OFF<=FILESIZE or that
> SZ<=FILESIZE.
I feel that the code should be readable and understandable, and reflect
its purpose. If the purpose of the code is to validate data read from a
file, validate that data in that context and report any problems
accordingly. Checking for overflow and reporting an error is not as
useful if your goal is to either (1) understand the code, or (2) fix the
problem data.
Given a choice between six checks that check for the actual problems in
a readable and easy to understand way, or a single complex check that
happens to catch the security aspects and yells "Error!", I'll pick the
former.
As for optimization, I leave that up to the compiler.
More information about the Libc-alpha
mailing list