mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
iconv: Bail out of the loop when an illegal sequence of bytes occurs.
Before, with the default codepage GB2312 and a mysql sql dump in UTF-8 I got segfaults in the iconv related code.
This commit is contained in:
parent
0ba951021a
commit
7dd4d9b737
@ -1344,7 +1344,7 @@ repeat:
|
||||
inp = iconv_input;
|
||||
outp = iconv_output;
|
||||
before = iconv_inleft;
|
||||
again:
|
||||
|
||||
v = iconv(iconv_cd, &inp, &iconv_inleft, &outp, &iconv_outleft);
|
||||
chars_offset += before - iconv_inleft;
|
||||
charslen = 256 * 8 - iconv_outleft;
|
||||
@ -1359,10 +1359,8 @@ again:
|
||||
iconv_offset = iconv_inleft;
|
||||
break;
|
||||
case EILSEQ:
|
||||
chars_offset++;
|
||||
iconv_inleft--;
|
||||
inp++;
|
||||
goto again;
|
||||
loop = 0;
|
||||
goto out;
|
||||
break;
|
||||
default:
|
||||
iconv_offset = 0;
|
||||
@ -1376,6 +1374,7 @@ again:
|
||||
#endif
|
||||
/* Iterate ;-) */
|
||||
|
||||
out:
|
||||
while (charspos < charslen) {
|
||||
const unsigned char *translit;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user