Loading ...
Sorry, an error occurred while loading the content.
 

Strange string parameter corruption with recent perl 5.6 to 5.8 upgrade

Expand Messages
  • b1v1r <b1v1r@yahoo.com>
    Hello, Sorry for the length of this post, but I wanted to include an example. I seem to be having a rather strange problem with passing some string parameters
    Message 1 of 1 , Jan 17, 2003
      Hello,

      Sorry for the length of this post, but I wanted to include an example.

      I seem to be having a rather strange problem with passing some string
      parameters to a method via SOAP::Lite 0.55 on perl 5.8.

      Basically, I am trying to call an authenticate($dn,$password) method
      that just tries to bind to an LDAP server, then return the success of
      that. After upgrading to perl 5.8 I started getting 'I/O Error' back
      from the LDAP server resulting from an 'unexpected data in PDU' error.
      So, I assumed it was an issue with LDAP and the perl upgrade, but
      after some debugging, it seems to be related to SOAP - if I bypass
      SOAP and call the method nativly I do not get an error, nor do I get
      an error if I just hardcode the parameters within the SOAP invoked
      method. But, when the parameters from the SOAP call that are passed
      directly to the LDAP call I get 'unexpected data in PDU' and an 'I/O
      Error' back from LDAP.

      So, I whipped up a simple example server and client to test this and
      the simple version has the same problem. Looking at the SOAP trace
      and XML (see end of email) shows nothing strange about the paramters
      and printing the parameters out within perl shows no corruption.
      Sending the SOAP parameters to the LDAP bind() call, however, shows
      the corruption.

      Below is the simplified code I am using to test this. The first call
      to authenticate() passes no parameters, so the server uses the
      defaults and I get back an 'Invalid Credentials' which is expected.
      But, the second call (which passes the exact same parameters as the
      hard-coded ones) gives me an 'I/O Error'. Also note that if you run
      the client a second time, without restarting the server, you get an
      'I/O Error' on both calls.

      I am at a loss as to where to look for the problem now. It seems to
      be related to SOAP, but it may also be an LDAP issue. Does anyone
      have any ideas? Can someone else try this (Code is below. You can
      use the same LDAP server, but you will most likely have to change
      'verify' => 'none' and/or remove 'cafile' in the server)?

      Some versions from my Debian Linux packages:

      Working machine:
      libsoap-lite-perl 0.55-1
      libsoap-perl 0.23-1
      libnet-ldap-perl 0.26-2
      libldap2 2.0.14-1
      libnet-ldap-pe 0.26-2
      perl 5.6.1-7

      Not-working machine:
      libsoap-lite-perl 0.55-4
      libsoap-perl 0.23-1
      libnet-ldap-perl 0.26-2
      libldap2 2.0.27-3
      libnet-ldap-perl 0.26-2
      perl 5.8.0-15

      Simplified client code (note that call w/params has the exact same
      params as what is used when not supplied):

      #!/usr/local/bin/perl

      use SOAP::Lite;

      $soap = new SOAP::Lite();
      $soap->readable(1);
      $som = $soap
      -> uri('http://localhost/TESTAPI')
      -> proxy('http://localhost:8580/')
      -> authenticate()
      ;
      ($result,@paramsout) = ($som->result,$som->paramsout);

      print "result(no param)='$result'
      paramsout=('".join("','",@paramsout)."')\n";

      $som = $soap
      -> uri('http://localhost/TESTAPI')
      -> proxy('http://localhost:8580/')
      -> authenticate('uupid=baduser,ou=accounts,dc=vt,dc=edu','badpass')
      ;
      ($result,@paramsout) = ($som->result,$som->paramsout);

      print "result(with param)='$result'
      paramsout=('".join("','",@paramsout)."')\n";

      The client outputs:

      result(no param)='0' paramsout=('49','Invalid credentials','')
      result(with param)='0' paramsout=('1','I/O Error ','I/O Error ')


      Here is the simplified server code:


      #!/usr/local/bin/perl

      package TESTAPI;

      use Net::LDAP;

      sub authenticate {
      ($this,$dn,$password) = @_;
      $dn = 'uupid=baduser,ou=accounts,dc=vt,dc=edu' unless(defined $dn);
      $password = 'badpass' unless(defined $password);

      print "Creating LDAP handle...";
      eval {
      $LDAP = new Net::LDAP(
      'authn.directory.vt.edu',
      'port' => 389,
      'version' => 3,
      # 'debug' => 0xffff, # Uncomment for tons of LDAP debugging
      );
      $mesg = $LDAP->start_tls(
      'verify' => 'require',
      'cafile' => "$ENV{'JCS_ROOT'}/ed_auth_cert.pem",
      'ciphers' => 'RC4-SHA',
      );
      };
      print((($@)?"FAILED: $@":"OK - $mesg")."\n");

      $ldapmesg = eval {
      print "Binding with: dn='$dn' password='$password'\n";
      $LDAP->bind(
      'dn' => $dn,
      'password' => $password,
      );
      };
      if($@) {
      print "LDAP bind() failed: $@\n";
      }

      return (0,-1,'','') if($@ or !defined $ldapmesg);

      $success = (!$ldapmesg->done or $ldapmesg->is_error) ? 0 : 1;
      $ldapcode = $ldapmesg->code() || -1;
      $ldapcodetext = $ldapmesg->error() || '';
      $ldapservererr = $ldapmesg->server_error() || '';
      print "LDAP bind() results: code='$ldapcode'
      codetext='$ldapcodetext' servererr='$ldapservererr'\n";

      $LDAP->unbind();
      undef $LDAP;

      return ($success,$ldapcode,$ldapcodetext,$ldapservererr);
      }

      1;

      use SOAP::Lite;
      #use SOAP::Lite +trace => qw(all); # Uncomment for SOAP tracing
      use SOAP::Transport::HTTP;

      $daemon = SOAP::Transport::HTTP::Daemon
      ->new (
      'LocalAddr' => '127.0.0.1',
      'LocalPort' => 8580,
      'ReuseAddr' => 1,
      )
      -> dispatch_to('TESTAPI')
      ;
      $daemon->serializer()->readable(1);
      print "Contact to SOAP server at ", $daemon->url, "\n";
      $daemon->handle;


      And the server outputs:

      Contact to SOAP server at http://localhost:8580/
      Creating LDAP handle...OK - Net::LDAP::Extension=HASH(0x8790864)
      Binding with: dn='uupid=baduser,ou=accounts,dc=vt,dc=edu'
      password='badpass'
      LDAP bind() results: code='49' codetext='Invalid credentials' servererr=''
      Creating LDAP handle...OK - Net::LDAP::Extension=HASH(0x878736c)
      Binding with: dn='uupid=baduser,ou=accounts,dc=vt,dc=edu'
      password='badpass'
      LDAP bind() results: code='1' codetext='I/O Error ' servererr='I/O
      Error '




      And, finally the Net dump of the two calls:

      ******** CALL 1 ********

      POST / HTTP/1.1
      Connection: close
      Accept: text/xml
      Accept: multipart/*
      Host: localhost:8580
      User-Agent: SOAP::Lite/Perl/0.55
      Content-Length: 469
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "http://localhost/TESTAPI#authenticate"

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      >
      <SOAP-ENV:Body
      >
      <namesp1:authenticate
      xmlns:namesp1="http://localhost/TESTAPI"/></SOAP-ENV:Body></SOAP-ENV:Envelope>

      HTTP/1.1 200 OK
      Date: Fri, 17 Jan 2003 19:43:45 GMT
      Server: libwww-perl-daemon/1.25
      Content-Length: 746
      Content-Type: text/xml; charset=utf-8
      SOAPServer: SOAP::Lite/Perl/0.55

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      >
      <SOAP-ENV:Body
      >
      <namesp1:authenticateResponse xmlns:namesp1="http://localhost/TESTAPI"
      >
      <s-gensym3 xsi:type="xsd:int"
      >0</s-gensym3>
      <s-gensym5 xsi:type="xsd:int"
      >49</s-gensym5>
      <s-gensym7 xsi:type="xsd:string"
      >Invalid credentials</s-gensym7>
      <s-gensym9
      xsi:type="xsd:string"/></namesp1:authenticateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

      ******** CALL 2 ********

      POST / HTTP/1.1
      Connection: close
      Accept: text/xml
      Accept: multipart/*
      Host: localhost:8580
      User-Agent: SOAP::Lite/Perl/0.55
      Content-Length: 659
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "http://localhost/TESTAPI#authenticate"

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      >
      <SOAP-ENV:Body
      >
      <namesp2:authenticate xmlns:namesp2="http://localhost/TESTAPI"
      >
      <c-gensym4 xsi:type="xsd:string"
      >uupid=baduser,ou=accounts,dc=vt,dc=edu</c-gensym4>
      <c-gensym6 xsi:type="xsd:string"

      >badpass</c-gensym6></namesp2:authenticate></SOAP-ENV:Body></SOAP-ENV:Envelope>

      HTTP/1.1 200 OK
      Date: Fri, 17 Jan 2003 19:43:45 GMT
      Server: libwww-perl-daemon/1.25
      Content-Length: 774
      Content-Type: text/xml; charset=utf-8
      SOAPServer: SOAP::Lite/Perl/0.55

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      >
      <SOAP-ENV:Body
      >
      <namesp2:authenticateResponse xmlns:namesp2="http://localhost/TESTAPI"
      >
      <s-gensym12 xsi:type="xsd:int"
      >0</s-gensym12>
      <s-gensym14 xsi:type="xsd:int"
      >1</s-gensym14>
      <s-gensym16 xsi:type="xsd:string"
      >I/O Error </s-gensym16>
      <s-gensym18 xsi:type="xsd:string"
      >I/O Error
      </s-gensym18></namesp2:authenticateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
    Your message has been successfully submitted and would be delivered to recipients shortly.