You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2006/07/10 00:38:36 UTC

DO NOT REPLY [Bug 39996] New: - apr_(v)snprintf wrong return value

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39996>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39996

           Summary: apr_(v)snprintf wrong return value
           Product: APR
           Version: 1.2.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: regenrecht@o2.pl
                CC: rooneg@electricjellyfish.net


apr_(v)snprintf from strings/apr_snprintf.c (according to apr_strings.h)
should return "the number of characters inserted into the buffer, not
including the terminating NUL". But, as for APR 1.2.7 (Arch Linux build),
that's not true if length of input string >= buffer limit. In that case
NUL byte is counted as well.

This code:

    char buff[8];
    printf("%d", apr_snprintf(buff, 8, "12345678"));

will return '8' instead of '7'.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 39996] - apr_(v)snprintf wrong return value

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39996>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39996


jorton@redhat.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From jorton@redhat.com  2006-07-11 14:12 -------
Thanks for the report and patch.  I've committed a slightly extended test case
and removed the unnecessary paranthesis from the *snprintf changes:

http://svn.apache.org/viewvc?view=rev&revision=420858

...will backport to 1.2.x after some further testing.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 39996] - apr_(v)snprintf wrong return value

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39996>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39996





------- Additional Comments From regenrecht@o2.pl  2006-07-09 22:41 -------
Created an attachment (id=18577)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=18577&action=view)
Just a simple patch - don't count NUL byte

Seems to work for me...

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 39996] - apr_(v)snprintf wrong return value

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39996>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39996





------- Additional Comments From regenrecht@o2.pl  2006-07-09 22:43 -------
Created an attachment (id=18578)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=18578&action=view)
Two more testcases, pro futuro


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.