|
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 theparameter is longer than what will fit into the output buffer) but I don'tsee 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 / \ --------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.