Package: libnet-socks-perl
Version: 0.03-4

In SOCKS.pm, the author wrote "#fixme - check to make sure peer_addr is dotted decimal or do name resolution on it first". I've fixed this with a small (hacky) patch (see attachment).

(The patch is needed, when using Net::SOCKS together with SpamAssassin.)

It would be nice if you could include this patch in the next Debian release and forward it to the upstream maintainer.

Feel free to contact me, if you need more info.


Cheers,

Chris

--- SOCKS.pm.ref        2006-11-27 15:15:04.000000000 +0100
+++ SOCKS.pm    2006-11-27 15:15:59.000000000 +0100
@@ -345,8 +345,22 @@
 
   if ($rc==SOCKS_OKAY) {
 
-#fixme - check to make sure peer_addr is dotted decimal or do name
-#        resolution on it first
+    # resolve name
+    unless (${*self}{peer_addr} =~ /^\d+\.\d+\.\d+\.\d+$/o) {
+      #die "peer_addr not an IP adress: ${*self}{peer_addr}\n";
+      #print STDERR "debug: peer_addr not an IP adress: ${*self}{peer_addr} -- 
resolving...\n";
+      my $res = Net::DNS::Resolver->new;
+      my $query = $res->search(${*self}{peer_addr});
+      my $ip;
+      if ($query) {
+        foreach my $rr ($query->answer) {
+          next unless $rr->type eq "A";
+          $ip = $rr->address;
+        }
+      }
+      $ip or die "cannot resolve name ${*self}{peer_addr}";
+      ${*self}{peer_addr} = $ip;
+    }
 
     # send the request
     print  { ${*self}{fh} } pack ('CCn', 4, $req_num, ${*self}{peer_port}) .

Reply via email to