Re: [Clax86list] Feedback please (Linux, NASM code)



Frank Kotler <spamtrap@xxxxxxxxxx> wrote:

Charles A. Crayne wrote:
On Wed, 22 Nov 2006 15:03:00 -0500
Frank Kotler <spamtrap@xxxxxxxxxx> wrote:

:(why the hell can't I find "itoa" in the man pages???)

Probably because the man pages spells it "sprintf",

Yipes! Isn't that dangerous? It was "sprintf" that allowed the buffer
overflow in Nasm - had to replace it with "snprintf". Well, won't be a
problem here...

If you are using sprintf to do the equivalent of itoa, then you have an
absolute upper bound on the size of the output string.

char xyz[12];
sprintf( xyz, "%d", i );

That can't overflow.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.

.



Relevant Pages

  • Re: Converting int to string
    ... >> As an old C programmer, I find itoa (or even sprintf!) most ... >using itoa is much faster. ... The function itoais not standard C or C++ and you ... If you love good programming techniques, ...
    (microsoft.public.vc.stl)
  • Re: [Clax86list] Feedback please (Linux, NASM code)
    ... :(why the hell can't I find "itoa" in the man pages???) ... Probably because the man pages spells it "sprintf", ...
    (comp.lang.asm.x86)
  • Re: itoa function in gcc
    ... Instead of 'itoa' use 'sprintf'. ... Should work on all compilers. ... Victor ...
    (comp.lang.cpp)
  • Re: integer/string conversion
    ... >snprintf is far saver than itoa, ... snprintf seems to me to be overkill for trivial int->string conversions. ... sprintf with a destination buffer of four chars. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Slow ostringstream?
    ... to generate a string buffer - besides old C style using charwith sprintf or itoa, ... any C++ language feature that is fast? ... sprintf is usually quite fast. ...
    (microsoft.public.vc.language)