[Bug locale/22908] iconv(3) fails on utf8->ascii with ILSEQ on valid seq

steffen at sdaoden dot eu sourceware-bugzilla@sourceware.org
Thu Mar 1 18:21:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=22908

--- Comment #1 from Steffen (Daode) Nurpmeso <steffen at sdaoden dot eu> ---
oh, sorry, hit RETURN to get rid of all the autocompletions.
The following program fails with

 $/tmp/zt
 Converting 4 <aäc>
 Fail <Invalid or incomplete multibyte or wide character>

whereas musl gives

 $./zt
 Converting 4 <aäc>
 GOT <a*c>

I.e., i would expect replacement to happen, but instead (size_t)-1 is returned.

#include <stdio.h> 
#include <string.h>
#include <iconv.h>
#include <errno.h>
int main(void){
   char inb[16], oub[16], *inbp, *oubp;
   iconv_t id;
   size_t inl, oul;

   memcpy(inbp = inb, "a\303\244c", sizeof("a\303\244c"));
   inl = sizeof("a\303\244c") -1;
   oul = sizeof oub;
   oubp = oub;

   if((id = iconv_open("ascii", "utf8")) == (iconv_t)-1)
     return 1;
   fprintf(stderr, "Converting %lu <%s>\n",(unsigned long)inl, inbp);
   if(iconv(id, &inbp, &inl, &oubp, &oul) == (size_t)-1){
      fprintf(stderr, "Fail <%s>\n", strerror(errno));
      return 2;
   }  
   fprintf(stderr, "GOT <%s>\n", oub);
   iconv_close(id);
   return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list