Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ping: check return value of write() to avoid integer overflow
Error: INTEGER_OVERFLOW (CWE-190): iputils-20240117/ping/ping.h:291: tainted_data_return: Called function "write(1, str + o, len - o)", and a possible return value may be less than zero. iputils-20240117/ping/ping.h:291: assign: Assigning: "cc" = "write(1, str + o, len - o)". iputils-20240117/ping/ping.h:292: overflow: The expression "o += cc" might be negative, but is used in a context that treats it as unsigned. iputils-20240117/ping/ping.h:291: overflow: The expression "len - o" is deemed underflowed because at least one of its arguments has underflowed. iputils-20240117/ping/ping.h:291: overflow_sink: "len - o", which might have underflowed, is passed to "write(1, str + o, len - o)". 289| ssize_t cc; 290| do { 291|-> cc = write(STDOUT_FILENO, str + o, len - o); 292| o += cc; 293| } while (len > o || cc < 0); Closes: iputils#545 Reviewed-by: Petr Vorel <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]> Signed-off-by: Jan Macku <[email protected]>
- Loading branch information