Skip to contentSkip to conversation

fence_scsi: fix regular expression for grep

PATCH New Ryan O'Hara 2 participants 2 messages Jan 19, 2011 – Jan 21, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fence_scsi: fix regular expression for grep

When fence_scsi checks to see if a specific keys is registered for a specific device, it uses grep to look through a list of all registered keys. The existing regular expression was not specific enough, and could result in false positives. This patch fixes the problem by using anchors to make the regular expression more specific.

Resolves: rhbz#670910

---
 fence/agents/scsi/fence_scsi.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fence/agents/scsi/fence_scsi.pl +2 -2
index 8ddde4e..818e1d9 100644
@@ -71,7 +71,7 @@ sub do_action_off ($@)
 	log_error ("device $dev does not exist") if (! -e $dev);
 	log_error ("device $dev is not a block device") if (! -b $dev);
 
-	my @keys = grep { /$node_key/ } get_registration_keys ($dev);
+	my @keys = grep { /^$node_key$/ } get_registration_keys ($dev);
 
 	if (scalar (@keys) != 0) {
 	    do_preempt_abort ($host_key, $node_key, $dev);
@@ -93,7 +93,7 @@ sub do_action_status ($@)
 	log_error ("device $dev does not exist") if (! -e $dev);
 	log_error ("device $dev is not a block device") if (! -b $dev);
 
-	my @keys = grep { /$node_key/ } get_registration_keys ($dev);
+	my @keys = grep { /^$node_key$/ } get_registration_keys ($dev);
 
 	if (scalar (@keys) != 0) {
 	    $dev_count++;
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 fence_scsi: fix regular expression for grep

Quoted 7 lines · Ryan O'Hara

When fence_scsi checks to see if a specific keys is registered for a specific device, it uses grep to look through a list of all registered keys. The existing regular expression was not specific enough, and could result in false positives. This patch fixes the problem by using anchors to make the regular expression more specific.

Resolves: rhbz#670910

ACK

-- Lon