[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #22800] sprintf() expands a 128char string parameter
From: |
David Prentice |
Subject: |
[avr-libc-dev] [bug #22800] sprintf() expands a 128char string parameter incorrectly |
Date: |
Tue, 01 Apr 2008 12:34:23 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 |
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] [bug #22800] sprintf() expands a 128char string parameter incorrectly,
David Prentice <=