libexecinfo: Include terminating null in byte count

Otherwise, a formatted string with a strlen equal to the remaining
buffer space would have the last character omitted (because vsnprintf
always null-terminates), and later the assert in backtrace_symbols_fmt
would fail.

MFC after:	3 days
Sponsored by:	DARPA, AFRL
This commit is contained in:
Ed Maste 2013-11-21 14:12:36 +00:00
parent 364871328e
commit 3e7aca6f4e

View File

@ -89,7 +89,7 @@ rasprintf(char **buf, size_t *bufsiz, size_t offs, const char *fmt, ...)
len = vsnprintf(*buf + offs, *bufsiz - offs, fmt, ap);
va_end(ap);
if (len < 0 || (size_t)len < *bufsiz - offs)
if (len < 0 || (size_t)len + 1 < *bufsiz - offs)
return len;
nbufsiz = MAX(*bufsiz + 512, (size_t)len + 1);
} else