diff options
-rw-r--r-- | pod/perldiag.pod | 10 | ||||
-rw-r--r-- | pp.c | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 8e686bab29..a068427c21 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -87,6 +87,16 @@ See L<perlfunc/pack>. checksumming process loses information, and you can't go the other way. See L<perlfunc/unpack>. +=item Repeat count in pack overflows + +(F) You can't specify a repeat count so large that it overflows +your signed integers. See L<perlfunc/pack>. + +=item Repeat count in unpack overflows + +(F) You can't specify a repeat count so large that it overflows +your signed integers. See L<perlfunc/unpack>. + =item /%s/: Unrecognized escape \\%c passed through (W) You used a backslash-character combination which is not recognized @@ -3350,8 +3350,11 @@ PP(pp_unpack) } else if (isDIGIT(*pat)) { len = *pat++ - '0'; - while (isDIGIT(*pat)) + while (isDIGIT(*pat)) { len = (len * 10) + (*pat++ - '0'); + if (len < 0) + Perl_croak(aTHX_ "Repeat count in unpack overflows"); + } } else len = (datumtype != '@'); @@ -4394,8 +4397,11 @@ PP(pp_pack) } else if (isDIGIT(*pat)) { len = *pat++ - '0'; - while (isDIGIT(*pat)) + while (isDIGIT(*pat)) { len = (len * 10) + (*pat++ - '0'); + if (len < 0) + Perl_croak(aTHX_ "Repeat count in pack overflows"); + } } else len = 1; |