]> git.gsnw.org Git - fping.git/commit
prevent allocation size computation overflow
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sat, 23 Aug 2025 12:52:08 +0000 (14:52 +0200)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sun, 24 Aug 2025 11:21:02 +0000 (13:21 +0200)
commita54fb46b5134c4fab044c07a0102b14a1970fe26
tree41087f367fe2d938736ef0624625b8e9700d3a01
parentf73b88c6411f21585f0d700a582420599e5cf522
prevent allocation size computation overflow

On systems where size_t is unsigned int, computing the size
of the resp_times array can overflow.  Add a check to prevent
this.

On a 64-bit x86_64 Ubuntu 22.04.5 LTS system, the overflow check
results in a compiler warning:

```
fping.c: In function ‘add_addr’:
fping.c:3444:20: warning: comparison is always false due to limited range of data type [-Wtype-limits]
 3444 |         if (trials > (SIZE_MAX / sizeof(int64_t)))
      |                    ^
```

Thus limit the check to systems with a size_t equal to (or less
than) unsigned int.
CHANGELOG.md
src/fping.c