Skip to content

Commit e4d1558

Browse files
committed
idn2_to_ascii_4i(): Restrict output length to 63
1 parent 0965b23 commit e4d1558

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: lib/lookup.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,18 @@ idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags
617617
* char * out output zero terminated string that must have room for at
618618
* least 63 characters plus the terminating zero.
619619
*/
620+
size_t len = strlen ((char *) output_u8);
621+
622+
if (len > 63)
623+
{
624+
free (output_u8);
625+
return IDN2_TOO_BIG_DOMAIN;
626+
}
627+
620628
if (output)
621-
strcpy (output, (const char *) output_u8);
629+
strcpy (output, (char *) output_u8);
622630

623-
free(output_u8);
631+
free (output_u8);
624632
}
625633

626634
return rc;

0 commit comments

Comments
 (0)