Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libexecinfo From Ed Maste:



details:   https://anonhg.NetBSD.org/src/rev/d697c72c0744
branches:  trunk
changeset: 791504:d697c72c0744
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 21 16:02:21 2013 +0000

description:
>From Ed Maste:

  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.

diffstat:

 lib/libexecinfo/backtrace.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r f1a9d0f0e792 -r d697c72c0744 lib/libexecinfo/backtrace.c
--- a/lib/libexecinfo/backtrace.c       Thu Nov 21 15:54:17 2013 +0000
+++ b/lib/libexecinfo/backtrace.c       Thu Nov 21 16:02:21 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: backtrace.c,v 1.3 2013/08/29 14:58:56 christos Exp $   */
+/*     $NetBSD: backtrace.c,v 1.4 2013/11/21 16:02:21 christos Exp $   */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: backtrace.c,v 1.3 2013/08/29 14:58:56 christos Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.4 2013/11/21 16:02:21 christos Exp $");
 
 #include <sys/param.h>
 #include <assert.h>
@@ -88,7 +88,7 @@
                        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



Home | Main Index | Thread Index | Old Index