URL:
<http://savannah.nongnu.org/bugs/?22800>
Summary: sprintf() expands a 128char string parameter
incorrectly
Project: AVR C Runtime Library
Submitted by: david_prentice
Submitted on: Tuesday 01/04/08 at 12:34
Category: Library
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: libc code
Status: None
Percent Complete: 0%
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Fixed Release: None
_______________________________________________________
Details:
In the unlikely event that a very long string parameter is sent to sprintf(),
the expanded string is a space padded 256 byte string. A regular (less than
128 bytes long) string behaves normally.
e.g.:
<pre>
#include <avr/io.h>
#include <stdio.h>
char buffer[300], string[200];
char tmp[] ="123";
int main ( void )
{
int i;
// just put some data to the buffer
for (i=0; i<129; i++)
{
string[i] = 'B';
}
// try to add a string to the buffer
sprintf (buffer,"%s%s",string,tmp);
while (1)
{
}
return 1;
}
</pre>
the buffer becomes: " ... BB...BB123"
instead of "BB...BB123"
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?22800>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev