Module Name: src Committed By: martin Date: Sat Dec 9 13:03:34 UTC 2023
Modified Files: src/lib/libc/gen [netbsd-10]: vis.c src/tests/lib/libc/gen [netbsd-10]: t_vis.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #485): lib/libc/gen/vis.c: revision 1.76-1.86 tests/lib/libc/gen/t_vis.c: revision 1.10-1.14 vis(3): Avoid nonportable MIN in portable code. vis(3) tests: Add xfail test for encoding overflow. >From Kyle Evans <kevans%FreeBSD.org@localhost>. PR lib/57573 vis(3) tests: Expand tests and diagnostic outputs on failure. PR lib/57573 vis(3) tests: Test another overflow edge case. Related to PR lib/57573. vis(3): Make maxolen unsigned size_t, not ssize_t. It is initialized once either to *dlen, which is unsigned size_t, or to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t too. So there appears to have never been any reason for this to be signed. Part of PR lib/57573. vis(3): Make mbslength unsigned. Sprinkle assertions and comments justifying the proposition that it would never go negative if signed. Obviates need to worry about mblength > SSIZE_MAX. Prompted by PR lib/57573. vis(3): Avoid arithmetic overflow before calloc(3). Prompted by PR lib/57573. vis(3): Call wcslen(start) only once. It had better not change between these two times! Prompted by PR lib/57573. vis(3): Avoid potential arithmetic overflow in maxolen. Can't easily prove that this overflow is impossible, so let's add a check. Prompted by PR lib/57573. vis(3): Fix main part of PR lib/57573. >From Kyle Evans <kevans%FreeBSD.org@localhost>. vis(3): Fix one more buffer overrun in an edge case. PR lib/57573 vis(3): Sort includes. No functional change intended. Prompted by PR lib/57573. vis(3): Need <stdint.h> for SIZE_MAX, per C standard. >From Kyle Evans <kevans%FreeBSD.org@localhost>. Followup to PR lib/57573. vis(3): Per KNF, sys/param.h comes before sys/types.h. Which is nice because that's also lexicographic. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.75.2.1 src/lib/libc/gen/vis.c cvs rdiff -u -r1.9 -r1.9.24.1 src/tests/lib/libc/gen/t_vis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.