mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibCrypto: Tweak ::prune_padding() to be more intuitive with loop bounds
This commit is contained in:
parent
b394543d3c
commit
4d932ce701
Notes:
sideshowbarker
2024-07-19 07:03:46 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/4d932ce7019 Pull-request: https://github.com/SerenityOS/serenity/pull/1661 Reviewed-by: https://github.com/Dexesttp Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/itamar8910
1 changed files with 4 additions and 4 deletions
|
@ -68,8 +68,8 @@ protected:
|
|||
// cannot be padding (the entire block cannot be padding)
|
||||
return;
|
||||
}
|
||||
for (auto i = maybe_padding_length; i > 0; --i) {
|
||||
if (data[size - i] != maybe_padding_length) {
|
||||
for (auto i = size - maybe_padding_length; i < size; ++i) {
|
||||
if (data[i] != maybe_padding_length) {
|
||||
// not padding, part of data
|
||||
return;
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ protected:
|
|||
return;
|
||||
}
|
||||
// FIXME: If we want to constant-time operations, this loop should not stop
|
||||
for (auto i = maybe_padding_length; i > 0; --i) {
|
||||
if (data[size - i - 1] != maybe_padding_length) {
|
||||
for (auto i = size - maybe_padding_length - 1; i < size; ++i) {
|
||||
if (data[i] != maybe_padding_length) {
|
||||
// note that this is likely invalid padding
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue