summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-03-25 11:02:26 +0000
committertb <>2023-03-25 11:02:26 +0000
commitbddc9afa59372fc8260efa868af7df1545308326 (patch)
tree979dbe222125aa0a174dea895cfc7ca90433e810 /src
parentd042453006fa5ae2921e034c968a20389c94f15c (diff)
downloadopenbsd-bddc9afa59372fc8260efa868af7df1545308326.tar.gz
openbsd-bddc9afa59372fc8260efa868af7df1545308326.tar.bz2
openbsd-bddc9afa59372fc8260efa868af7df1545308326.zip
Add checks to ensure the uint16_t array isn't overflowed when this
script is run. This is more of an issue with uint16_t now than it was with prime_t aka BN_ULONG before r1.6.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_prime.pl4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/libcrypto/bn/bn_prime.pl b/src/lib/libcrypto/bn/bn_prime.pl
index bc85909bfb..4692e7f419 100644
--- a/src/lib/libcrypto/bn/bn_prime.pl
+++ b/src/lib/libcrypto/bn/bn_prime.pl
@@ -4,6 +4,9 @@
4$num=2048; 4$num=2048;
5$num=$ARGV[0] if ($#ARGV >= 0); 5$num=$ARGV[0] if ($#ARGV >= 0);
6 6
7# The 6543rd prime is 2^16 + 1.
8die "$num must be smaller than 6543" if $num >= 6543;
9
7push(@primes,2); 10push(@primes,2);
8$p=1; 11$p=1;
9loop: while ($#primes < $num-1) 12loop: while ($#primes < $num-1)
@@ -46,6 +49,7 @@ for ($i=0; $i <= $#primes; $i++)
46 } else { 49 } else {
47 printf(" "); 50 printf(" ");
48 } 51 }
52 die "\$primes[$i] is too large: $primes[$i]" if $primes[$i] > 65535;
49 printf("%5d,",$primes[$i]); 53 printf("%5d,",$primes[$i]);
50 } 54 }
51print "\n};\n"; 55print "\n};\n";