diff options
author | tb <> | 2023-03-25 11:02:26 +0000 |
---|---|---|
committer | tb <> | 2023-03-25 11:02:26 +0000 |
commit | bddc9afa59372fc8260efa868af7df1545308326 (patch) | |
tree | 979dbe222125aa0a174dea895cfc7ca90433e810 /src | |
parent | d042453006fa5ae2921e034c968a20389c94f15c (diff) | |
download | openbsd-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.pl | 4 |
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. | ||
8 | die "$num must be smaller than 6543" if $num >= 6543; | ||
9 | |||
7 | push(@primes,2); | 10 | push(@primes,2); |
8 | $p=1; | 11 | $p=1; |
9 | loop: while ($#primes < $num-1) | 12 | loop: 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 | } |
51 | print "\n};\n"; | 55 | print "\n};\n"; |