On Fri, May 02, 2008 at 04:29:07PM +0400, Andrew Savchenko wrote:
This as well is very wrong. It is just wrong on 64 bit systems, it is possibly exploitable (since it does not check for *buf == NULL) and it seems overcomplicated to me anyway, IMO just restart from scratch by calling iconv(*icnv, NULL, NULL, NULL, NULL);
Well, I'm thinking about offset calculation in another way... I can use memcpy of course, but this seems ugly for me. I don't want to recall iconv() from scratch due to performance issues: this function may be very slow.
This function (at least so far) is basically never called during playback so unless you expect iconv to talk almost 0.5 s there is not really an issue. Also it only happens when the buffer is too small which should be quite rare as well.
It's probably a good idea to do this for all errors.
At least for EILSEQ error code this will be a problem. EILSEQ occurs when invalid multibyte sequence was encountered, so buffer will be grown until out of memory. Perhaps we should just copy the problem character as is and issue a warning? This is still better than nothing.
You misunderstood me: You should not increase buffer size on other errors, but I think it would be a good idea to reset iconv state on all errors. Greetings, Reimar Döffinger