Fix uninitialised value created by stack allocation

Using valgrind testing the fuzz corpora revealed a missing
check in _add_punycode_if_needed() which lead to a
"Uninitialised value was created by a stack allocation".

Thanks to OSS-fuzz for the corpora, thanks valgrind to find this
issue (asan and ubsan didn't find it).
This commit is contained in:
Tim Rühsen 2017-07-09 20:21:55 +02:00
parent d583db99b8
commit 926cc34ade
1 changed files with 5 additions and 4 deletions

View File

@ -772,10 +772,11 @@ static void _add_punycode_if_needed(_psl_idna_t *idna, _psl_vector_t *v, _psl_en
_psl_entry_t suffix, *suffixp;
/* fprintf(stderr, "toASCII '%s' -> '%s'\n", e->label_buf, lookupname); */
_suffix_init(&suffix, lookupname, strlen(lookupname));
suffix.flags = e->flags;
if ((suffixp = _vector_get(v, _vector_add(v, &suffix))))
suffixp->label = suffixp->label_buf; /* set label to changed address */
if (_suffix_init(&suffix, lookupname, strlen(lookupname)) == 0) {
suffix.flags = e->flags;
if ((suffixp = _vector_get(v, _vector_add(v, &suffix))))
suffixp->label = suffixp->label_buf; /* set label to changed address */
}
} /* else ignore */
free(lookupname);