1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

#99748 catch runtime errors occurring when user input for the MATCH operator is not a proper regex

This commit is contained in:
Laurent Dami 2014-11-25 04:30:57 +01:00
parent 28fc0e459e
commit 13e2b63d26
2 changed files with 10 additions and 2 deletions

View file

@ -214,7 +214,14 @@ sub NEXT {
do {
$self->{row_ix} += 1
} until $self->EOF || $self->{is_wanted_row}->($self, $self->{row_ix});
} until $self->EOF
|| eval {$self->{is_wanted_row}->($self, $self->{row_ix})};
# NOTE: the eval above is required for cases when user data, injected
# into Perl comparison operators, generates errors; for example
# WHERE col MATCH '(foo' will die because the regex is not well formed
# (no matching parenthesis). In such cases no row is selected and the
# query just returns an empty list.
}

View file

@ -12,7 +12,8 @@ use Test::NoWarnings;
# tests that the MATCH operator does not allow code injection
my @interpolation_attempts = (
'@{[die -1]}',
# '(?{die 999})', # Eval-group not allowed at runtime
'(foobar', # will die - incorrect regex
'(?{die 999})', # will die - Eval-group not allowed at runtime
'$foobar',
'$self->{row_ix}',
'$main::ARGV[ die 999 ]',