mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -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;
|
inp = iconv_input;
|
||||||
outp = iconv_output;
|
outp = iconv_output;
|
||||||
before = iconv_inleft;
|
before = iconv_inleft;
|
||||||
again:
|
|
||||||
v = iconv(iconv_cd, &inp, &iconv_inleft, &outp, &iconv_outleft);
|
v = iconv(iconv_cd, &inp, &iconv_inleft, &outp, &iconv_outleft);
|
||||||
chars_offset += before - iconv_inleft;
|
chars_offset += before - iconv_inleft;
|
||||||
charslen = 256 * 8 - iconv_outleft;
|
charslen = 256 * 8 - iconv_outleft;
|
||||||
@ -1359,14 +1359,12 @@ again:
|
|||||||
iconv_offset = iconv_inleft;
|
iconv_offset = iconv_inleft;
|
||||||
break;
|
break;
|
||||||
case EILSEQ:
|
case EILSEQ:
|
||||||
chars_offset++;
|
loop = 0;
|
||||||
iconv_inleft--;
|
goto out;
|
||||||
inp++;
|
|
||||||
goto again;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
iconv_offset = 0;
|
iconv_offset = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
iconv_offset = 0;
|
iconv_offset = 0;
|
||||||
}
|
}
|
||||||
@ -1376,6 +1374,7 @@ again:
|
|||||||
#endif
|
#endif
|
||||||
/* Iterate ;-) */
|
/* Iterate ;-) */
|
||||||
|
|
||||||
|
out:
|
||||||
while (charspos < charslen) {
|
while (charspos < charslen) {
|
||||||
const unsigned char *translit;
|
const unsigned char *translit;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user