nmh-workers
[Top][All Lists]
Advanced

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

Re: [Nmh-workers] mhshow(1) iconv(3) Bug if Multibyte Straddles Buffer E


From: David Levine
Subject: Re: [Nmh-workers] mhshow(1) iconv(3) Bug if Multibyte Straddles Buffer End.
Date: Sat, 15 Oct 2016 11:49:22 -0400

Ralph wrote:

> 1.6's mhshow(1) says

Might Ken's commit adfed5f72bc07ac7de8dfc62188338d4d4f25a38
have fixed this?

> I took a look at mhshowsbr.c's convert_charset() and I think it's
> failing to handle an EINVAL return.

That commit adds handling of EINVAL and EISLEQ, relevant portion of
the diff is below.

David

+       if (errno == EINVAL) {
+           /* middle of multi-byte sequence */
+           if (write (fd, dest_buffer, outbytes_before - outbytes) < 0) {
+               advise (dest, "write");
+           }
+           fseeko (*fp, -inbytes, SEEK_CUR);
+           if (end > 0) bytes_to_read += inbytes;
+           /* advise(NULL, "convert_charset: EINVAL"); */
+           continue;
+       }
+       if (errno == EILSEQ) {
+           /* invalid multi-byte sequence */
+           if (fromutf8) {
+               for (++ib, --inbytes;
+                    inbytes > 0 &&
+                           (((unsigned char) *ib) & 0xc0) == 0x80;
+                    ++ib, --inbytes)
+                   continue;
+           } else {
+               ib++; inbytes--; /* skip it */
+           }
+           (*ob++) = '?'; outbytes --;
+           /* advise(NULL, "convert_charset: EILSEQ"); */
+           goto iconv_start;
+       }
+       advise (NULL, "convert_charset: errno = %d", errno);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]