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) {