Source-Changes-HG archive

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

[src/trunk]: src/external/cddl/osnet/dist/lib/libdtrace/common format is a po...



details:   https://anonhg.NetBSD.org/src/rev/7278b465495d
branches:  trunk
changeset: 794878:7278b465495d
user:      apb <apb%NetBSD.org@localhost>
date:      Thu Mar 27 19:34:39 2014 +0000

description:
format is a pointer, so sizeof(format) is not a good length
to pass to snprintf.  Try to calculate the correct length,
taking into account the amount of space already used.

diffstat:

 external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (16 lines):

diff -r 0da55eb23071 -r 7278b465495d external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c
--- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c Thu Mar 27 18:28:26 2014 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c Thu Mar 27 19:34:39 2014 +0000
@@ -1861,10 +1861,10 @@
                        *f++ = '@';
 
                if (width != 0)
-                       f += snprintf(f, sizeof (format), "%d", width);
+                       f += snprintf(f, format + formatlen - f, "%d", width);
 
                if (prec != 0)
-                       f += snprintf(f, sizeof (format), ".%d", prec);
+                       f += snprintf(f, format + formatlen - f, ".%d", prec);
 
                /*
                 * If the output format is %s, then either %s is the underlying



Home | Main Index | Thread Index | Old Index