Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src



Module Name:    src
Committed By:   rillig
Date:           Thu Feb 22 21:04:24 UTC 2024

Modified Files:
        src/common/lib/libutil: snprintb.c
        src/lib/libutil: snprintb.3
        src/tests/lib/libutil: t_snprintb.c

Log Message:
snprintb: always null-terminate output

Always null-terminate the output in the buffer, even in error cases. The
wording in the manual page has been promising this since 2008. For
snprintb_m, ensure that the output is terminated with two null
characters, to gracefully handle situations in which the caller does not
check whether snprintb returned an error.

If the buffer size is zero, allow the buffer to be a null pointer,
analogous to snprintf.

Fix an out-of-bounds memory read if the bitfmt ends with a '*' directive
(since today).

In the tests, merge the helper functions for snprintb, snprintb_m, as
they were similar enough.

Fix a few 'line_max exceeded' tests, ensuring that they output a '#'
marker, and that the 'complete' tests don't.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/common/lib/libutil/snprintb.c
cvs rdiff -u -r1.34 -r1.35 src/lib/libutil/snprintb.3
cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libutil/t_snprintb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index