Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix but index out of bonds while parsing range based consent strings #21

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- fix a bug while parsing valid consent strings range-based, see https://github.com/peczenyj/GDPR-IAB-TCFv2/issues/20

0.083
- refactor on Publisher Restriction parsing.
- small fixes about data and offset.
Expand Down
2 changes: 1 addition & 1 deletion lib/GDPR/IAB/TCFv2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ sub _is_vendor_consent_range_encoding {
sub _parse_range_section {
my ( $self, $max_id, $range_section_start_offset ) = @_;

my $data = substr( $self->{data}, $range_section_start_offset, $max_id );
my $data = substr( $self->{data}, $range_section_start_offset );

my ( $range_section, $next_offset ) =
GDPR::IAB::TCFv2::RangeSection->Parse(
Expand Down
2 changes: 1 addition & 1 deletion t/01-parse.t
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ subtest "invalid tcf consent string candidates" => sub {
GDPR::IAB::TCFv2->Parse(
'COvcSpYOvcSpYC9AAAENAPCAAAAAAAAAAAAAAFQBgAAgABAACAAEAAQAAgAA')
}
qr/index out of bounds on offset 0: can't read 12, only has: 10/,
qr/index out of bounds on offset 360: can't read 1, only has: 360/,
'this test uses a crafted consent uses range section, declares 10 vendors, 6 exceptions and legitimate interest without require';


Expand Down
26 changes: 26 additions & 0 deletions t/03-bugs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use strict;
use warnings;

use Test::More;
use Test::Exception;

use GDPR::IAB::TCFv2;

subtest
"BUG index out of bounds on offset, see: https://github.com/peczenyj/G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7AkQCRQEqAJWATFAmQCZQE2gJ2AUPAo8CkQFJwKaApsBT4CoYFSAVKAqoBVgCuQFdgLCgWIBYoCygFogLUAWxAtwC3QFwALkAXQAu0Bd8C8gLzAX0Av8BggDBgGGgMQAYsAx4BkMDIwMkgZMBk4DKgGWAMzAZyAzwBokDRgNHAaaA1MBqsDVwNZAa8A2iBtwG3gNygboBuoDgAHBAOLAceA5OBywHLgOfAeKA8eB5IHlAPigfIB8oD6QH1wPtA-6B-wH7gQBAgIBAwCB4EEQIJgQYAg2BCECFAEK4IWghcBDECGcEOQQ6gh4CHoEPwIpgRgAjSBGsCN4EcQI6AR2Aj2BH0CP4EhAJFASNgkgCScEmASZglQCVIEsAJZwS3BLiCXQJdgS-AmABMMCYsEzATOAmoBNiCbYJuATeCDUAUSAAwABEGoMABgACINQoADAAEQaigAGAAIg1DgAMAARBqCAAYAAiDUQAAwABEGoQABgACINQwADAAEQaiwAGAAIg1AAA.f_gAD_gAAAAA';
lives_ok {
$consent = GDPR::IAB::TCFv2->Parse($tc_string);
}
'should not throw exception';

isa_ok $consent, 'GDPR::IAB::TCFv2', 'gdpr iab tcf v2 consent';

done_testing;
};

done_testing;