[ 
https://issues.apache.org/jira/browse/STDCXX-857?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Travis Vitek resolved STDCXX-857.
---------------------------------

    Resolution: Won't Fix

I think the behavior of the rw_asnprintf is as expected. If the caller uses a 
static buffer, they are expected (required) to indicate maximum number of 
characters to be written to the buffer using the %{*} or %{n} format specifier.

The guard bytes that trigger the assertion were added in 
[r351515|http://svn.apache.org/viewvc?view=rev&revision=351515] to
detect two things. It checks for buffer overflow and that the buffer was 
allocated with a previous call to _rw_bufcat(). Unfortunately there wasn't 
anything there to indicate that this was expected behavior and that the caller 
was using the function improperly.

> unexpected assertion from _rw_bufcat
> ------------------------------------
>
>                 Key: STDCXX-857
>                 URL: https://issues.apache.org/jira/browse/STDCXX-857
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: Test Driver
>    Affects Versions: 4.2.1
>            Reporter: Travis Vitek
>            Assignee: Travis Vitek
>             Fix For: 4.2.1
>
>   Original Estimate: 2h
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> Here is the assertion...
> {noformat}
> ..\..\..\tests\src\printf.cpp:486: char *__cdecl _rw_bufcat(struct Buffer 
> &,const char *,unsigned int): Assertion '0 == memcmp (*buf.pbuf + 
> *buf.pbufsize, guard, guardsize)' failed.
> {noformat}
> Here is a testcase...
> {noformat}
> #include <rw_printf.h>
> #include <string.h>
> #include <stdlib.h>
> int main (int argc, char* argv[])
> {
>     const char* s = 1 < argc ? argv [1] : "bug-zapper";
>     char buffer [4];
>     char *buf = buffer;
>     size_t bufsize = sizeof buffer;
>     rw_asnprintf (&buf, &bufsize, "%s", s);
>     if (buf != buffer)
>         free (buf);
>     return 0;
> }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to