mirror_zfs/cmd
Richard Yao f954ea26a6 zdb: Handle theoretical buffer overflow when printing float
CodeQL pointed out that for extreme floating point values, `sprintf()`
will overwrite a 32 character buffer. It cited 1e304 as an example,
which causes `sprintf()` to print 308 characters.

In practice, the numbers should never exceed 100, so this should not
happen. To silence the warning and also handle unexpected situations, we
change the code to use `snprintf()`.

This was missed during my audit of our use of `sprintf()`, since I did
not think to consider extreme floating point representations. It also
really should not happen, so this change is purely defensive
programming.

This was found by CodeQL's cpp/overrunning-write-with-float check.

Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14264
2022-12-08 14:15:15 -08:00
..
raidz_test Fix multiplication converted to larger type 2022-10-28 09:30:37 -07:00
zdb zdb: Handle theoretical buffer overflow when printing float 2022-12-08 14:15:15 -08:00
zed zed: unclean disk attachment faults the vdev 2022-11-29 09:24:10 -08:00
zfs Fix GCC 12 compilation errors 2022-11-30 13:45:53 -08:00
zinject Fix unsafe string operations 2022-09-27 16:47:24 -07:00
zpool Fix potential buffer overflow in zpool command 2022-12-08 14:14:30 -08:00
zpool_influxdb Fix unchecked return values 2022-09-29 09:02:57 -07:00
zstream Add ability to recompress send streams with new compression algorithm 2022-11-10 15:23:46 -08:00
arc_summary Remove ambiguity on demand vs prefetch stats reported by arc_summary 2022-10-04 11:00:02 -07:00
arcstat.in arcstat: fix -p option 2022-08-12 14:21:52 -07:00
dbufstat.in Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
fsck.zfs.in cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
Makefile.am Add zilstat script to report zil kstats in a user friendly manner 2022-09-02 13:24:07 -07:00
mount_zfs.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_ids_to_path.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zgenhostid.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zhack.c Cleanup: zhack should not declare function prototypes in main() 2022-12-08 13:51:24 -08:00
zilstat.in Add zilstat script to report zil kstats in a user friendly manner 2022-09-02 13:24:07 -07:00
ztest.c ztest: comparisons against errno should not assign to it 2022-12-08 14:15:04 -08:00
zvol_wait zvol_wait logic may terminate prematurely 2022-10-11 12:12:04 -07:00