| 1 |
From ae091790398088a66b22fa572856bfeb4db4c78a Mon Sep 17 00:00:00 2001 |
| 2 |
From: "H.Merijn Brand - Tux" <[email protected]> |
| 3 |
Date: Thu, 28 May 2026 10:06:33 +0200 |
| 4 |
Subject: [PATCH] New test for DBI-1.648 CVE fix |
| 5 |
|
| 6 |
Origin: https://github.com/perl5-dbi/DBD-CSV/commit/ae091790398088a66b22fa572856bfeb4db4c78a |
| 7 |
Bug: https://github.com/perl5-dbi/DBD-CSV/issues/12 |
| 8 |
Bug-Debian: https://bugs.debian.org/1139509 |
| 9 |
|
| 10 |
--- |
| 11 |
t/70_csv.t | 24 +++++++++++++++++++++++- |
| 12 |
t/lib.pl | 3 +-- |
| 13 |
3 files changed, 26 insertions(+), 4 deletions(-) |
| 14 |
|
| 15 |
diff --git a/t/70_csv.t b/t/70_csv.t |
| 16 |
index 30d2d59..a65385a 100644 |
| 17 |
--- a/t/70_csv.t |
| 18 |
+++ b/t/70_csv.t |
| 19 |
@@ -3,6 +3,7 @@ |
| 20 |
use strict; |
| 21 |
use warnings; |
| 22 |
use Test::More; |
| 23 |
+use File::Spec; |
| 24 |
|
| 25 |
BEGIN { use_ok ("DBI"); } |
| 26 |
do "./t/lib.pl"; |
| 27 |
@@ -85,12 +86,33 @@ ok ($dbh = Connect ($dsn), "connect"); |
| 28 |
# Check, whether the csv_tables->{$tbl}{file} attribute works |
| 29 |
like (my $def4 = TableDefinition ($tbl4, @tbl_def), |
| 30 |
qr{^create table $tbl4}i, "table definition"); |
| 31 |
-ok ($dbh->{csv_tables}{$tbl4}{file} = DbFile ($tbl4), "set table/file"); |
| 32 |
+{ my $dbf4 = DbFile ($tbl4); |
| 33 |
+ my $dbd4 = DbDir (); |
| 34 |
+ |
| 35 |
+ $dbh->{f_dir_search} = [ $dbd4 ]; |
| 36 |
+ ok ($dbh->{csv_tables}{$tbl4}{file} = $dbf4, "set table/file"); |
| 37 |
+ } |
| 38 |
ok ($dbh->do ($def4), "create table"); |
| 39 |
ok (-f DbFile ($tbl4), "does exists"); |
| 40 |
|
| 41 |
ok ($dbh->do ("drop table $tbl4"), "drop table"); |
| 42 |
|
| 43 |
+if ($DBI::VERSION ge "1.648") { |
| 44 |
+ ok (my $tbl5 = FindNewTable ($dbh), "find new test table"); |
| 45 |
+ my $dir5 = File::Spec->catdir (DbDir (), "not-in-scope"); |
| 46 |
+ mkdir $dir5; |
| 47 |
+ ok (my $dbf5 = File::Spec->catdir ($dir5, $tbl5), "in bad location"); |
| 48 |
+ ok (!-f $dbf5, "does not exist"); |
| 49 |
+ ok ($dbh->{csv_tables}{$tbl5}{file} = $dbf5, "set to illegal location"); |
| 50 |
+ { my @d; |
| 51 |
+ local $SIG{__DIE__} = sub { push @d => @_ }; |
| 52 |
+ local $dbh->{PrintError} = 0; |
| 53 |
+ eval { $dbh->do ("create table $tbl5 (x char)"); }; |
| 54 |
+ like ("@d", qr{is unsafe and not allowed}, "unsafe caught"); |
| 55 |
+ }; |
| 56 |
+ rmdir $dir5; |
| 57 |
+ } |
| 58 |
+ |
| 59 |
ok ($dbh->disconnect, "disconnect"); |
| 60 |
undef $dbh; |
| 61 |
|
| 62 |
diff --git a/t/lib.pl b/t/lib.pl |
| 63 |
index 9050d91..74e3f0f 100644 |
| 64 |
--- a/t/lib.pl |
| 65 |
+++ b/t/lib.pl |
| 66 |
@@ -116,8 +116,7 @@ END { DbCleanup (); } |
| 67 |
|
| 68 |
my $testtable = "testaa"; |
| 69 |
|
| 70 |
- sub FindNewTable |
| 71 |
- { |
| 72 |
+ sub FindNewTable { |
| 73 |
my $dbh = shift; |
| 74 |
|
| 75 |
my @tables = defined $listTablesHook ? $listTablesHook->($dbh) |
| 76 |
-- |
| 77 |
2.53.0 |
| 78 |
|