On 9/14/09 9:54 PM, Andrew Farmer said:
Yes, sprintf is pure evil. snprintf is less evil.
Also, I recommend adding -fstack-protector -D_FORTIFY_SOURCE=2, they
can
help catch some of these problems. And valgrind would probably have
caught this problem immediately.
Sadly, valgrind hasn't
On 9/13/09 12:01 PM, Jens Alfke said:
It would be best to convert all your sprintf calls to snprintf, which
is a safer equivalent that won't overflow the buffer.
Yes, sprintf is pure evil. snprintf is less evil.
Also, I recommend adding -fstack-protector -D_FORTIFY_SOURCE=2, they can
help
On 14 Sep 2009, at 11:48, Sean McBride wrote:
On 9/13/09 12:01 PM, Jens Alfke said:
It would be best to convert all your sprintf calls to snprintf, which
is a safer equivalent that won't overflow the buffer.
Yes, sprintf is pure evil. snprintf is less evil.
Also, I recommend adding
Hi,
I'm updating my code for Snow Leopard and ran into this problem. The
app crashes at this line:
sprintf(str, %d, val);
where val is a CFIndex. According to the string programming guide here...
On Sep 13, 2009, at 10:59 AM, slasktrattena...@gmail.com wrote:
I'm updating my code for Snow Leopard and ran into this problem. The
app crashes at this line:
sprintf(str, %d, val);
where val is a CFIndex. According to the string programming guide
here...
On Sun, Sep 13, 2009 at 8:01 PM, Bill Bumgarner b...@mac.com wrote:
On Sep 13, 2009, at 10:59 AM, slasktrattena...@gmail.com wrote:
I'm updating my code for Snow Leopard and ran into this problem. The
app crashes at this line:
sprintf(str, %d, val);
where val is a CFIndex. According to the
On Sep 13, 2009, at 11:10 AM, slasktrattena...@gmail.com wrote:
On Sun, Sep 13, 2009 at 8:01 PM, Bill Bumgarner b...@mac.com wrote:
On Sep 13, 2009, at 10:59 AM, slasktrattena...@gmail.com wrote:
I'm updating my code for Snow Leopard and ran into this problem. The
app crashes at this line:
On Sun, Sep 13, 2009 at 8:10 PM, slasktrattena...@gmail.com
slasktrattena...@gmail.com wrote:
On Sun, Sep 13, 2009 at 8:01 PM, Bill Bumgarner b...@mac.com wrote:
On Sep 13, 2009, at 10:59 AM, slasktrattena...@gmail.com wrote:
I'm updating my code for Snow Leopard and ran into this problem. The
char str[10];
sprintf(str, %d, val);
What is the value of val at the time the crash occurs? Will it
always convert to 9 digits or less?
What value is sprintf() returning?
You might want to use snprintf() or asprintf().
-- GG
___
Cocoa-dev
In this case val was exactly nine digits: 213294334. But it can also
be greater sometimes.
Sprintf() is returning the same value, using %d on 10.5.
On Sun, Sep 13, 2009 at 8:21 PM, Greg Guerin glgue...@amug.org wrote:
char str[10];
sprintf(str, %d, val);
What is the value of val at the time
Sprintf() is returning the same value, using %d on 10.5.
I meant sprintf()'s returned int value, which is the count of
formatted output chars, not including the trailing null. Read 'man
sprintf'.
Or just try the simple expedient:
char str[80];
-- GG
It would be best to convert all your sprintf calls to snprintf, which
is a safer equivalent that won't overflow the buffer. If the value is
too long to fit, it'll be truncated instead of overflowing and
corrupting the stack. (This type of overflow is one of the main causes
of security
On Sun, Sep 13, 2009 at 8:42 PM, Greg Guerin glgue...@amug.org wrote:
Or just try the simple expedient:
char str[80];
-- GG
Right, it was a buffer overrun. Simple as that. Thanks guys!
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
13 matches
Mail list logo