On 08/04/2006, at 6:34 AM, Scott Klement wrote:

It's true that there might be input that doesn't get translated (if the
parameter is longer than what will fit into the output buffer) but I don't
see how it could overwrite another area of memory...

It won't overwrite storage but it may print more than it should. Because you set the input length to strlen(argv[1]) you are effectively removing the null-terminator on the input string. Thus iconv() will not include a null-terminator in the converted output. Thus printf() on the ASCII string may print additional characters that just happen to be in outbuf. Not a big deal in a trivial example like this but in a loop it becomes apparent. Easy to fix though.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].