Skip Menu |

This queue is for tickets about the Net-Milter CPAN distribution.

Report information
The Basics
Id: 43134
Status: new
Priority: 0/
Queue: Net-Milter

People
Owner: Nobody in particular
Requestors: joshua_anderson [...] mac.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09
Fixed in: (no value)



Subject: Protocol negotiation function doesn't return negotiated options
The protocol_negotiation function always returns references to empty arrays. The problem is that shift() is used to get the contents of the @action_types and @content_types when constructing the bitmask for negotiation, leaving them empty when they are used to build the @returned_actions and @returned_protocol arrays. I've attached a patch to fix this. Note: I didn't use a foreach loop because the semantics of shift() guarantee that we'll always get array elements in the order we want. Foreach loops *do* appear to always iterate over arrays in left-to-right order, but I don't see anything in the docs guaranteeing that behavior. Another option is to re-initialize @action_types and @content_types before building @returned_actions and @returned_protocol.
Subject: patch.txt
diff --git a/Milter.pm b/Milter.pm index 8a462d8..8fdfdc9 100644 --- a/Milter.pm +++ b/Milter.pm @@ -80,13 +80,15 @@ sub protocol_negotiation { my (@content_types) = @{$self->{content_types}}; my ($count,$action,$content); + my @temp; if ($DEBUG==1) {print STDERR "\tsetting bits\n";} my $action_field = 0; $count=0; - while ($action = shift(@action_types)) { + @temp = @action_types; + while ($action = shift(@temp)) { if (defined($options{$action}) && $options{$action}==0) { # do nothing } @@ -102,7 +104,8 @@ sub protocol_negotiation { my $protocol_field = 0; $count=0; - while ($content = shift(@content_types)) { + @temp = @content_types; + while ($content = shift(@temp)) { if (defined($options{$content}) && $options{$content}==1) { $protocol_field = $protocol_field | 2**$count; } @@ -153,7 +156,8 @@ sub protocol_negotiation { my (@returned_actions, @returned_protocol); $count=0; - while ($action = shift(@action_types)) { + @temp = @action_types; + while ($action = shift(@temp)) { if ($ret_actions & 2**$count) { push @returned_actions,$action; } @@ -161,7 +165,8 @@ sub protocol_negotiation { } # end while $count=0; - while ($content = shift(@content_types)) { + @temp = @content_types; + while ($content = shift(@temp)) { if ($ret_protocol & 2**$count) { push @returned_protocol,$content; }