Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-18025: Improve test case and consistency checks
Write a test case that computes valid crc32 checksums for an encrypted page, but zeroes out the payload area, so that the checksum after decryption fails. xb_fil_cur_read(): Validate the page number before trying any checksum calculation or decrypting or decompression. Also, skip zero-filled pages. For page_compressed pages, ensure that the FIL_PAGE_TYPE was changed. Also, reject FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED if no decryption was attempted.
- Loading branch information
Showing
4 changed files
with
97 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# The following is Public Domain / Creative Commons CC0 from | ||
# http://billauer.co.il/blog/2011/05/perl-crc32-crc-xs-module/ | ||
|
||
sub mycrc32 { | ||
my ($input, $init_value, $polynomial) = @_; | ||
|
||
$init_value = 0 unless (defined $init_value); | ||
$polynomial = 0xedb88320 unless (defined $polynomial); | ||
|
||
my @lookup_table; | ||
|
||
for (my $i=0; $i<256; $i++) { | ||
my $x = $i; | ||
for (my $j=0; $j<8; $j++) { | ||
if ($x & 1) { | ||
$x = ($x >> 1) ^ $polynomial; | ||
} else { | ||
$x = $x >> 1; | ||
} | ||
} | ||
push @lookup_table, $x; | ||
} | ||
|
||
my $crc = $init_value ^ 0xffffffff; | ||
|
||
foreach my $x (unpack ('C*', $input)) { | ||
$crc = (($crc >> 8) & 0xffffff) ^ $lookup_table[ ($crc ^ $x) & 0xff ]; | ||
} | ||
|
||
$crc = $crc ^ 0xffffffff; | ||
|
||
return $crc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters