tags 486698 +patch
thanks

I think I may have a fix for this bug.

I'm getting very similar symptoms (LDAP search causing the script to
exit with code 141; I didn't try to catch SIGPIPE). The script works
under etch but fails under lenny. Stepping through with the perl
debugger I found out that in the following piece of code:

Net::LDAP::_sendmesg(/usr/share/perl5/Net/LDAP.pm:797):
797:        my $n = syswrite($socket, substr($$to_send, $offset, 15000), 15000)
798:          or return _error($ldap, $mesg, LDAP_LOCAL_ERROR,"$!");

syswrite() always returns 1. The crash occurs during the third iteration
through the loop (at which point $offset == 2).

If I apply the attached patch to Authen/SASL/Cyrus/Security.pm
syswrite() returns the actual length written.

I'm only 99% sure that this is the same bug as found by Wouter Verhelst;
maybe he can try my patch and report back? In any case, the patch is worth 
applying.
--- Authen/SASL/Cyrus/Security.pm	2008-05-03 07:41:05.000000000 +0200
+++ Authen/SASL/Cyrus/Security.pm	2009-02-26 18:13:45.347494100 +0100
@@ -77,6 +77,7 @@
 
   $fh = $ref->{fh};
   $clearbuf = substr($string, 0, $len);
+  $len = length($clearbuf);
   $maxbuf = $ref->{conn}->property("maxout");
   if ($len < $maxbuf) {
     $cryptbuf = $ref->{conn}->encode($clearbuf);
@@ -94,7 +95,7 @@
       $offset += $chunksize;
     }
   }
-  print $fh $cryptbuf;
+  return (print $fh $cryptbuf) ? $len : -1;
 }
 
 # Given a GLOB ref, tie the filehandle of the GLOB to this class

Reply via email to