[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#406946: iconv() crashes during ASCII -> WCHAR_T conversion on sparc



On Sat, Feb 03, 2007 at 06:01:16PM +0100, Aurelien Jarno wrote:
> > 
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <iconv.h>
> > #include <string.h>
> > 
> > int main()
> > {
> >         iconv_t cd;
> >         size_t inr = 4, outr = 8, res;
> >         char *inbuf = strdup("abcde");
> >         char *outbuf = malloc(8);
> > 
> >         inbuf++;
> >         cd = iconv_open("ASCII", "WCHAR_T");
> >         res = iconv(cd, &inbuf, &inr, &outbuf, &outr);
> > 
> >         return 0;
> > }
> 
> wchar_t type has a 32-bit size. It is perfectly normal to require a
> 32-bit alignement on 32-bit types, just like it is already the case on
> float and double.
> 
> This testcase is buggy, not the iconv code.

I disagree. iconv(3) man page states, that the input and output buffer 
are specified as char **inbuf and char **outbuf, implying that there 
are no specific alignment requirements for them. I also could not find 
any mention of possible alignment issues in the documentation. Thus, I 
think it is reasonable to expect that a valid iconv() implementation 
will not to do any assumptions about the alignment of data buffers 
which are passed to it.

Best regards,
-- 
Jurij Smakov                                           jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC



Reply to: