Skip to content

Commit 1133f87

Browse files
Replace binary test file with ASCII text file
t/data/binary-test.file is a binary blob of unknown provenance. To provide more reassurance that nothing malicious is hidden in binary blobs in the test suite, replace this file with the ASCII text file t/data/lorem-ipsum.txt, which contains the first two paragraphs of lorem ipsum generated by https://lipsum.com with lines wrapped at 80 characters. Closes #475.
1 parent 53b94e4 commit 1133f87

File tree

6 files changed

+68
-25
lines changed

6 files changed

+68
-25
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Revision history for Perl extension Net::SSLeay.
44
- Skip NPN tests when NPN is disabled in OpenSSL instead o
55
assuming NPN is always enabled. Reported by GitHub user
66
dilyanpalauzov Дилян Палаузов.
7+
- In the test suite, replace t/data/binary-test.file (a binary blob with
8+
unknown provenance) with t/data/lorem-ipsum.txt (a text file containing
9+
widely-known ASCII text).
710

811
1.94 2024-01-08
912
- New stable release incorporating all changes from developer releases 1.93_01

MANIFEST

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ README.OSX
4444
README.VMS
4545
README.Win32
4646
SSLeay.xs
47-
t/data/binary-test.file
47+
t/data/lorem-ipsum.txt
4848
t/data/openssl_init_test.conf
4949
t/data/extended-cert.cert.der
5050
t/data/extended-cert.cert.dump

t/data/binary-test.file

-4.88 KB
Binary file not shown.

t/data/lorem-ipsum.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vitae nisl
2+
porta, maximus orci a, varius risus. Integer nisl lectus, convallis non
3+
convallis sit amet, maximus sodales magna. Donec cursus, diam non pellentesque
4+
ornare, diam diam laoreet justo, auctor finibus sem justo non mi. Suspendisse
5+
efficitur eget orci ut condimentum. Nunc tempor eleifend varius. Vestibulum at
6+
sapien non lacus fermentum viverra. Maecenas faucibus libero vel molestie
7+
finibus. Curabitur eu nisl arcu. Morbi egestas, libero pellentesque pharetra
8+
bibendum, magna lorem efficitur nisl, id placerat nisi sem eget ex. Donec non
9+
metus ultrices, lobortis arcu sit amet, sagittis felis. Proin molestie lectus
10+
et nisi sollicitudin blandit. Quisque cursus imperdiet nisl, vitae consectetur
11+
lacus ullamcorper nec. Donec pellentesque libero at dapibus ultricies. Nullam
12+
ut lorem vitae mi dapibus hendrerit eget nec nisl.
13+
14+
Etiam purus nulla, porta et fringilla sed, maximus id odio. Mauris mattis nibh
15+
id consectetur finibus. Curabitur hendrerit augue nec magna malesuada
16+
suscipit. Quisque dui dolor, volutpat ac iaculis et, cursus eu arcu. Cras ut
17+
nisi ut risus laoreet eleifend. Nunc accumsan, leo in malesuada rhoncus, diam
18+
tortor blandit odio, ac pretium nisl lacus commodo nisl. Nam et feugiat
19+
libero. Praesent rutrum erat sit amet euismod venenatis. Integer dictum
20+
tincidunt urna, sit amet facilisis nibh tristique et. Aliquam sed sapien in
21+
ipsum lacinia viverra. Maecenas ante arcu, pretium volutpat varius ac, ornare
22+
sed ante. Quisque eleifend, dui a molestie vestibulum, urna diam imperdiet ex,
23+
eget eleifend nibh tortor vitae quam. Phasellus ac consequat arcu, a tempus
24+
quam. Etiam ut rhoncus turpis. In id est magna.

t/local/10_rand.t

+28-9
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,36 @@ is_libressl() ?
1818
test_rand_file_name_openssl();
1919

2020
# RAND_load_file
21-
my $binary_file = data_file_path('binary-test.file');
22-
my $binary_file_size = -s $binary_file;
23-
24-
cmp_ok($binary_file_size, '>=', 1000, "Have binary file with good size: $binary_file $binary_file_size");
25-
is(Net::SSLeay::RAND_load_file($binary_file, $binary_file_size), $binary_file_size, 'RAND_load with specific size');
26-
if (Net::SSLeay::constant("LIBRESSL_VERSION_NUMBER"))
27-
{
21+
my $text_file = data_file_path('lorem-ipsum.txt');
22+
my $text_file_size = -s $text_file;
23+
24+
cmp_ok(
25+
$text_file_size,
26+
'>=',
27+
1000,
28+
"Have file with good size: $text_file $text_file_size"
29+
);
30+
31+
is(
32+
Net::SSLeay::RAND_load_file($text_file, $text_file_size),
33+
$text_file_size,
34+
'RAND_load with specific size'
35+
);
36+
37+
if ( Net::SSLeay::constant('LIBRESSL_VERSION_NUMBER') ) {
2838
# RAND_load_file does nothing on LibreSSL but should return something sane
29-
cmp_ok(Net::SSLeay::RAND_load_file($binary_file, -1), '>', 0, 'RAND_load with -1 is positive with LibreSSL');
39+
cmp_ok(
40+
Net::SSLeay::RAND_load_file($text_file, -1),
41+
'>',
42+
0,
43+
'RAND_load with -1 is positive with LibreSSL'
44+
);
3045
} else {
31-
is(Net::SSLeay::RAND_load_file($binary_file, -1), $binary_file_size, 'RAND_load with -1 returns file size');
46+
is(
47+
Net::SSLeay::RAND_load_file($text_file, -1),
48+
$text_file_size,
49+
'RAND_load with -1 returns file size'
50+
);
3251
}
3352

3453
test_rand_bytes();

t/local/50_digest.t

+12-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ sub digest_chunked_f1 {
1616
Net::SSLeay::EVP_DigestInit($ctx, $md);
1717

1818
open my $fh, "<", $file or BAIL_OUT "cannot open file '$file'";
19-
binmode $fh;
2019
while(my $len = sysread($fh, my $chunk, 500)) {
2120
Net::SSLeay::EVP_DigestUpdate($ctx,$chunk);
2221
}
@@ -36,7 +35,6 @@ sub digest_chunked_f2 {
3635
Net::SSLeay::EVP_DigestInit_ex($ctx, $md, 0); #NULL ENGINE just to test whether the function exists
3736

3837
open my $fh, "<", $file or BAIL_OUT "cannot open file '$file'";
39-
binmode $fh;
4038
while(my $len = sysread($fh, my $chunk, 5)) {
4139
Net::SSLeay::EVP_DigestUpdate($ctx,$chunk);
4240
}
@@ -60,7 +58,6 @@ sub digest_file {
6058
}
6159

6260
open my $f, "<", $file or BAIL_OUT "cannot open file '$file'";
63-
binmode $f;
6461
sysread($f, my $data, -s $file) or BAIL_OUT "sysread failed";
6562
close $f;
6663

@@ -177,20 +174,20 @@ SKIP: {
177174
isnt(scalar(keys %all_digests), 0, 'non-empty digest list');
178175
}
179176

180-
my $file = data_file_path('binary-test.file');
177+
my $file = data_file_path('lorem-ipsum.txt');
181178

182179
my $file_digests = {
183-
md2 => '67ae6d821be6898101414c56b1fb4f46',
184-
md4 => '480438696e7d9a6ab3ecc1e2a3419f78',
185-
md5 => 'cc89b43c171818c347639fa5170aee16',
186-
mdc2 => 'ee605fe3fc966a7b17185ebdbcd13ada',
187-
ripemd160 => 'cb70ba43fc6d263f6d7816170c1a33f28c2000fe',
188-
sha => 'c151c6f408cb94bc5c53b17852efbe8bfbeec2b9',
189-
sha1 => '059404d1d0e952d0457a6c99b6e68b3b44c8ef13',
190-
sha224 => '161c65efa1b9762f7e0448b5b369a3e2c236876b0b57a35add5106bb',
191-
sha256 => 'e416730ddaa34729adb32ec6ddad4e50fca1fe97de313e800196b1f8cd5032bd',
192-
sha512 => '8b5e7181fc76d49e1cb7971a6980b5d8db6b23c3b0553cf42f559156fd08e64567d17c4147c864efd4d3a5e22fb6602d613a055f7f14faad22744dbc3df89d59',
193-
whirlpool => '31079767aa2dd9b8ab01caadd954a88aaaf6001941c38d17ba43c0ef80a074c3eedf35b73c3941929dea281805c6c5ffc0a619abef4c6a3365d6cb31412d0e0c',
180+
md2 => '70982048c26bc1b0e4a14882143c43db',
181+
md4 => '10d7111dd6931a247b88ad05a6389ade',
182+
md5 => '92798fe3cda6fd622e1de6f78fe2ba78',
183+
mdc2 => 'eba3531b18827ec79aa4b421c63e6931',
184+
ripemd160 => '0976116cd4513f81d9696811d72c68e6d59ce73c',
185+
sha => 'aa862084fa60357fd983fb78945c4870e8c455a1',
186+
sha1 => '6bddd57399253c98ce7e1e1478426e317a6545ed',
187+
sha224 => '3ea7316d84881fbff013e6852ad0767e605352ae1fbdc43105f91701',
188+
sha256 => '76043f712d7c45bfad74bc0187b4eb259027193f68718e642fba976ec638b4ac',
189+
sha512 => '593ed012548e15bd43e4a3fa95b7c9bdf43c1c6aa1e42ed8a7ad3ef87a40fbfa4503bf95b5e9ecf17fc9398958968e9766c171ac6cf268f9394b0de73e78e3b2',
190+
whirlpool => '6216e98b1a920b14010f58c96299c738d4a156b7b533c74c9ae6da60e936958687017b8398d34efb05526e6156386f1af0b07f1b4af6feb41d6b45975d579a14',
194191
};
195192

196193
my %fps = (

0 commit comments

Comments
 (0)