summaryrefslogtreecommitdiffstats
path: root/contrib/libexecinfo/backtrace.c
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2013-11-21 14:12:36 +0000
committeremaste <emaste@FreeBSD.org>2013-11-21 14:12:36 +0000
commitbb4ff000de429abf7115b8d078833c468387f1dd (patch)
tree4476ee33b7ae8b421b1e3ebfa9163da037666380 /contrib/libexecinfo/backtrace.c
parent2b0e2fd586d8aa4dc336e3b1c06ed008b2f1f84f (diff)
downloadFreeBSD-src-bb4ff000de429abf7115b8d078833c468387f1dd.zip
FreeBSD-src-bb4ff000de429abf7115b8d078833c468387f1dd.tar.gz
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
Diffstat (limited to 'contrib/libexecinfo/backtrace.c')
-rw-r--r--contrib/libexecinfo/backtrace.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/contrib/libexecinfo/backtrace.c b/contrib/libexecinfo/backtrace.c
index 756a982..7dbf0bb 100644
--- a/contrib/libexecinfo/backtrace.c
+++ b/contrib/libexecinfo/backtrace.c
@@ -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
OpenPOWER on IntegriCloud