summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldiag.pod10
-rw-r--r--pp.c10
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
diff --git a/pp.c b/pp.c
index 8437e5b40c..a020f54589 100644
--- a/pp.c
+++ b/pp.c
@@ -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;