fix bug in decode_rfc2047()
authorPhilipp Takacs <philipp@bureaucracy.de>
Fri, 12 Aug 2016 15:43:05 +0000 (17:43 +0200)
committerPhilipp Takacs <philipp@bureaucracy.de>
Fri, 12 Aug 2016 15:48:38 +0000 (17:48 +0200)
If iconv() returns an error and the source encoding
is utf-8, the character jump has an of by one: the
source string is incresed by one possition more the
the length is decreased.

sbr/fmt_rfc2047.c

index 4145139..687ea57 100644 (file)
@@ -318,8 +318,12 @@ decode_rfc2047(char *str, char *dst, size_t dstlen)
                                                        break;
                                                /* skip to next input character */
                                                if (fromutf8) {
                                                        break;
                                                /* skip to next input character */
                                                if (fromutf8) {
-                                                       for (start++;(start < q) && ((*start & 192) == 128);start++)
+                                                       inbytes--;
+                                                       start++;
+                                                       while ((start < q) && ((*start & 192) == 128)) {
+                                                               start++;
                                                                inbytes--;
                                                                inbytes--;
+                                                       }
                                                } else
                                                        start++, inbytes--;
                                                if (start >= q)
                                                } else
                                                        start++, inbytes--;
                                                if (start >= q)