These are standard, either in POSIX or C23.
The semantics are slightly different as the error path does not
enforce null-termination in the function itself, so enforce that
by hand. As a nice side effect, this makes those error paths
easier to audit.