misc/152042: wrong bufsize of __hdtoa

Yui NARUSE naruse at airemix.jp
Mon Nov 8 09:40:07 UTC 2010


>Number:         152042
>Category:       misc
>Synopsis:       wrong bufsize of __hdtoa
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 08 09:40:06 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Yui NARUSE
>Release:        8.1-RELEASE
>Organization:
>Environment:
FreeBSD windy.airemix.net 8.1-RELEASE FreeBSD 8.1-RELEASE #1: Sat Jul 24 11:27:04 JST 2010     naruse at windy.airemix.net:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
When ndigits is given for __hdtoa, the bufsize for rv_alloc is too small.
It must add 1 for NUL termination.
>How-To-Repeat:

>Fix:
/usr/src/lib/libc/gdtoa % diff -u _hdtoa.c _hdtoa.c.orig
--- _hdtoa.c    2010-11-08 18:31:46.000000000 +0900
+++ _hdtoa.c.orig       2010-11-08 18:31:44.000000000 +0900
@@ -109,7 +109,7 @@
         * enough space for all the digits.
         */
        bufsize = (ndigits > 0) ? ndigits : SIGFIGS;
-       s0 = rv_alloc(bufsize);
+       s0 = rv_alloc(bufsize+1);
 
        /* Round to the desired number of digits. */
        if (SIGFIGS > ndigits && ndigits > 0) {

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list