Security Advisories (2)
CVE-2006-10002 (2026-03-19)

XML::Parser versions through 2.45 for Perl could overflow the pre-allocated buffer size cause a heap corruption (double free or corruption) and crashes. A :utf8 PerlIO layer, parse_stream() in Expat.xs could overflow the XML input buffer because Perl's read() returns decoded characters while SvPV() gives back multi-byte UTF-8 bytes that can exceed the pre-allocated buffer size. This can cause heap corruption (double free or corruption) and crashes.

CVE-2006-10003 (2026-03-19)

XML::Parser versions through 2.47 for Perl has an off-by-one heap buffer overflow in st_serial_stack. In the case (stackptr == stacksize - 1), the stack will NOT be expanded. Then the new value will be written at location (++stackptr), which equals stacksize and therefore falls just outside the allocated buffer. The bug can be observed when parsing an XML file with very deep element nesting

NAME

XML::Parser::Style::Stream - Stream style for XML::Parser

SYNOPSIS

use XML::Parser;
my $p = XML::Parser->new(Style => 'Stream', Pkg => 'MySubs');
$p->parsefile('foo.xml');

{
  package MySubs;
  
  sub StartTag {
    my ($e, $name) = @_;
    # do something with start tags
  }
  
  sub EndTag {
    my ($e, $name) = @_;
    # do something with end tags
  }
  
  sub Characters {
    my ($e, $data) = @_;
    # do something with text nodes
  }
}

DESCRIPTION

This style uses the Pkg option to find subs in a given package to call for each event. If none of the subs that this style looks for is there, then the effect of parsing with this style is to print a canonical copy of the document without comments or declarations. All the subs receive as their 1st parameter the Expat instance for the document they're parsing.

It looks for the following routines:

  • StartDocument

    Called at the start of the parse .

  • StartTag

    Called for every start tag with a second parameter of the element type. The $_ variable will contain a copy of the tag and the %_ variable will contain attribute values supplied for that element.

  • EndTag

    Called for every end tag with a second parameter of the element type. The $_ variable will contain a copy of the end tag.

  • Text

    Called just before start or end tags with accumulated non-markup text in the $_ variable.

  • PI

    Called for processing instructions. The $_ variable will contain a copy of the PI and the target and data are sent as 2nd and 3rd parameters respectively.

  • EndDocument

    Called at conclusion of the parse.