From 853a9093a24c8b75b76252774221cbf89d5b1abd Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 16 May 2008 18:47:32 +0000 Subject: [PATCH] -Rest of fix for bug 1965012. gettab now checks for valid column names, Table.pm properly formats the SQL statement so SQLite won't blow up in the prepare phase when searching for NULL entries. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1428 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Table.pm | 3 +-- xCAT-server-2.0/lib/xcat/plugins/tabutils.pm | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Table.pm b/perl-xCAT-2.0/xCAT/Table.pm index 1095bd05b..9989b5d49 100644 --- a/perl-xCAT-2.0/xCAT/Table.pm +++ b/perl-xCAT-2.0/xCAT/Table.pm @@ -1478,7 +1478,6 @@ sub getAttribs my @exeargs; foreach (keys %keypairs) { - if ($keypairs{$_}) { $statement .= "\"".$_ . "\" = ? and "; @@ -1493,7 +1492,7 @@ sub getAttribs } else { - $statement .= "$_ is NULL and "; + $statement .= "\"$_\" is NULL and "; } } $statement .= "(\"disable\" is NULL or \"disable\" in ('0','no','NO','No','nO'))"; diff --git a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm index 168447d6c..8ec739967 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm @@ -153,6 +153,10 @@ sub gettab foreach (@keypairs) { (my $key, my $value) = split /=/, $_; + unless (defined $key) { + gettab_usage(1); + return; + } $keyhash{$key} = $value; } @@ -164,6 +168,15 @@ sub gettab $tabhash{$table}->{$column} = 1; } + #Sanity check the key against all tables in question + foreach my $tabn (keys %tabhash) { + foreach my $kcheck (keys %keyhash) { + unless (grep /^$kcheck$/, @{$xCAT::Schema::tabspec{$tabn}->{cols}}) { + $callback->({error => ["Unkown key $kcheck to $tabn"],errorcode=>[1]}); + return; + } + } + } # Get the requested columns from each table foreach my $tabn (keys %tabhash) {