[Samba] Conversion error: Illegal multibyte sequence

Jeremy Allison jra at samba.org
Fri Sep 6 14:54:16 MDT 2013


On Fri, Sep 06, 2013 at 09:40:25PM +0200, Laurent Blume wrote:
> On 2013-09-05 11:34 PM, Jeremy Allison wrote:
> > No, it doesn't make sense. smb_iconv() vectors
> > through pull and push function pointers that
> > do the actual conversion - that's where the
> > errno is coming from. That's why you need
> > debug statements - you know it's going into
> > smb_iconv() but you don't know where it's
> > going from there.
> > 
> > Jeremy.
> > 
> 
> At least those proved that neither Solaris' nor GNU's iconv were
> involved :-)
> 
> I tagged all the possibles causes for EILSEQ, so here's the code causing
> that issue, in lib/util/charset/iconv.c:
> 
>                 if ((c[0] & 0xf0) == 0xe0) {
>                         if (in_left < 3 ||
>                             (c[1] & 0xc0) != 0x80 ||
>                             (c[2] & 0xc0) != 0x80) {
>                                 errno = EILSEQ;
>                                 DEBUG(3,("DEBUG, %d, %d, %d, %d\n",
> in_left, c[0], c[1], c[2]));
>                                 goto error;
>                         }
> 
> It happens because in_left == 2 when it should be 3:
> 
> [2013/09/06 20:59:50.249004,  3] ../lib/util/charset/iconv.c:600(utf8_pull)
>   DEBUG, 2, 226, 153, 187
> [2013/09/06 20:59:50.249056,  3] lib/charcnv.c:161(convert_string_internal)
>   convert_string_internal: Conversion error: Illegal multibyte
> sequence(â<99>»_Corbeille)
> 
> The sequence values are good, as this char is 0xE2 0x99 0xBB in UTF8.
> 
> I tried to backtrack the origin of this value, but I got lost after
> convert_string_internal() in source3/lib/charcnv.c , where it was
> incorrect already.
> 
> Is it getting warmer?

Yes ! The tests against 0x80 are correct, so as you've
surmised it's the in_left == 2 is the real problem.

If after the DEBUG(3,("..)) statement you have
here you cause it to terminate with abort(),
then you can catch the backtrace if you set

panic action = /bin/sleep 999999

in the [global] section of your smb.conf. At
that point you should be able to attach to
the parent process of the sleep (which will
be an smbd) with gdb, and examine the contents
of i_len inside convert_string_internal().

Either that or add another debug inside
convert_string_internal() to print out
the values of srclen and i_len at various
points and try and determine why it's off
by one.

Cheers,

	Jeremy.


More information about the samba mailing list