Skip to content

Commit 2709980

Browse files
doughera88rjbs
authored andcommitted
avoid calling memset with a negative count
Poorly written perl code that allows an attacker to specify the count to perl's 'x' string repeat operator can already cause a memory exhaustion denial-of-service attack. A flaw in versions of perl before 5.15.5 can escalate that into a heap buffer overrun; coupled with versions of glibc before 2.16, it possibly allows the execution of arbitrary code. The flaw addressed to this commit has been assigned identifier CVE-2012-5195.
1 parent 2c8ca68 commit 2709980

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,6 +3256,9 @@ Perl_repeatcpy(register char *to, register const char *from, I32 len, register I
32563256
{
32573257
PERL_ARGS_ASSERT_REPEATCPY;
32583258

3259+
if (count < 0)
3260+
Perl_croak_nocontext("%s",PL_memory_wrap);
3261+
32593262
if (len == 1)
32603263
memset(to, *from, count);
32613264
else if (count) {

0 commit comments

Comments
 (0)