mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-18 16:49:18 +03:00
Make chris' work compile without warning and not infinite-loop where I spotted it
This commit is contained in:
parent
eee7189f05
commit
4641769ae5
21
utils/idna.c
21
utils/idna.c
@ -94,13 +94,13 @@ static idna_unicode_jt idna__jt_property(int32_t cp)
|
||||
*/
|
||||
static bool idna__contexto_rule(int32_t cp)
|
||||
{
|
||||
bool rule = false;
|
||||
int32_t *t = idna_contexto;
|
||||
while (*t) {
|
||||
if (*t == cp) rule = true;
|
||||
};
|
||||
int32_t *t;
|
||||
for (t = idna_contexto; *t != 0; t++) {
|
||||
if (*t == cp)
|
||||
return true;
|
||||
}
|
||||
|
||||
return rule;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -485,20 +485,21 @@ static bool idna__verify(const char *label, size_t len)
|
||||
nserror error;
|
||||
int32_t *ucs4;
|
||||
char *ace;
|
||||
size_t ucs4_len, ace_len;
|
||||
ssize_t ucs4_len;
|
||||
size_t u_ucs4_len, ace_len;
|
||||
|
||||
/* Convert our ACE label back to UCS-4 */
|
||||
error = idna__ace_to_ucs4(label, len,
|
||||
&ucs4, &ucs4_len);
|
||||
&ucs4, &u_ucs4_len);
|
||||
if (error != NSERROR_OK) return false;
|
||||
|
||||
/* Perform NFC normalisation */
|
||||
ucs4_len = utf8proc_normalise(ucs4, ucs4_len,
|
||||
ucs4_len = utf8proc_normalise(ucs4, u_ucs4_len,
|
||||
UTF8PROC_STABLE | UTF8PROC_COMPOSE);
|
||||
if(ucs4_len < 0) return false;
|
||||
|
||||
/* Convert the UCS-4 label back to ACE */
|
||||
error = idna__ucs4_to_ace(ucs4, ucs4_len,
|
||||
error = idna__ucs4_to_ace(ucs4, (size_t)ucs4_len,
|
||||
&ace, &ace_len);
|
||||
free(ucs4);
|
||||
if (error != NSERROR_OK) return false;
|
||||
|
@ -387,7 +387,7 @@ ssize_t utf8proc_decompose(
|
||||
if (decomp_result < 0) return decomp_result;
|
||||
wpos += decomp_result;
|
||||
/* prohibiting integer overflows due to too long strings: */
|
||||
if (wpos < 0 || wpos > SSIZE_MAX/sizeof(int32_t)/2)
|
||||
if (wpos < 0 || wpos > (ssize_t)(SSIZE_MAX/sizeof(int32_t)/2))
|
||||
return UTF8PROC_ERROR_OVERFLOW;
|
||||
}
|
||||
}
|
||||
|
@ -4946,7 +4946,7 @@ const uint16_t utf8proc_stage2table[] = {
|
||||
0, };
|
||||
|
||||
const utf8proc_property_t utf8proc_properties[] = {
|
||||
{0, 0, 0, 0, NULL, false, -1, -1, -1, -1, -1, false},
|
||||
{0, 0, 0, 0, NULL, false, -1, -1, -1, -1, -1, false, false, false, false, NULL},
|
||||
{UTF8PROC_CATEGORY_CC, 0, UTF8PROC_BIDI_CLASS_BN, 0, NULL, false, -1, -1, -1, -1, -1, false, true, true, false, NULL},
|
||||
{UTF8PROC_CATEGORY_CC, 0, UTF8PROC_BIDI_CLASS_S, 0, NULL, false, -1, -1, -1, -1, -1, false, false, true, false, NULL},
|
||||
{UTF8PROC_CATEGORY_CC, 0, UTF8PROC_BIDI_CLASS_B, 0, NULL, false, -1, -1, -1, -1, -1, false, false, true, false, NULL},
|
||||
|
Loading…
Reference in New Issue
Block a user