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

4642Re: expat parse error causes call stack corruption

Expand Messages
  • kgoess
    May 4 4:59 PM
    • 0 Attachment
      It's a definite bug in 0.60 and 0.60a and I see it's been fixed in
      0.65_3.

      If a parse failure occurs the SOAP::Parser doesn't clear its state
      before the next parse, so you're going to get the results of the
      previous parse.

      Below is the fix for 0.60a and demonstration code.


      --- lib/SOAP/Lite.pm.orig 2005-05-04 16:52:00.810619056 -0700
      +++ lib/SOAP/Lite.pm 2005-05-04 16:52:33.903588160 -0700
      @@ -1283,21 +1283,28 @@
      sub decode { SOAP::Trace::trace('()');
      my $self = shift;

      $self->parser->setHandlers(
      Final => sub { shift; $self->final(@_) },
      Start => sub { shift; $self->start(@_) },
      End => sub { shift; $self->end(@_) },
      Char => sub { shift; $self->char(@_) },
      ExternEnt => sub { shift; die "External entity (pointing to
      '$_[1]') is not allowed" },
      );
      - my $parsed = $self->parser->parse($_[0]);
      + #my $parsed = $self->parser->parse($_[0]);
      + #need to clear values on parse failure
      + my $parsed;
      + eval { $parsed = $self->parser->parse($_[0])};
      + if ($@) {
      + undef $self->{_values};
      + }
      +
      return $parsed;
      }


      -----------------------------------------
      use SOAP::Lite;

      package MySOAPServer;

      sub myMethod {
      print "got '$_[1]'\n";
      }

      package main;

      my $s = SOAP::Server->new-> dispatch_with(
      { 'urn:kgtest' => 'MySOAPServer',});

      my $xml = <<EOL;
      <Envelope>
      <Body>
      <namesp1:myMethod xmlns:namesp1="urn:kgtest">
      <delivery>tiger woods</delivery>
      </namesp1:myMethod>
      </Body>
      </Envelope>
      EOL

      $s->handle($xml); #prints "got 'tiger woods'"

      $s->handle('<junk><<');

      $xml =~ s/tiger woods/arnold palmer/;

      $s->handle($xml); #prints "got 'tiger woods'" *again*
    • Show all 2 messages in this topic