snprintf(9) allows NULL string if size is 0. But doing NULL pointer
authorbluhm <bluhm@openbsd.org>
Thu, 20 Jan 2022 17:11:30 +0000 (17:11 +0000)
committerbluhm <bluhm@openbsd.org>
Thu, 20 Jan 2022 17:11:30 +0000 (17:11 +0000)
commitbb22a51d4f21ac8b45d6a6a5140ad8edc919aaa6
tree72e39a48e44d2d0723a8971e49bc722f00d3887a
parent4fc676bcf7dfc80749a728247649c500203ca847
snprintf(9) allows NULL string if size is 0.  But doing NULL pointer
arithmetic is undefined behavior.  Check that size is positive
before adding to pointer.  While there, use NUL char for string
termination.
found by kubsan; joint work with tobhe@; OK millert@
sys/kern/subr_prf.c