@@ -558,17 +558,28 @@ again:
558
558
my $offset = 0;
559
559
my ($len , $type );
560
560
561
- if (!length ($self -> {frames_incomplete }[$stream ]{buf })) {
562
- ($len , $type ) = parse_int(substr ($buf , $offset ));
563
- $offset += $len ;
564
- ($len , $length ) = parse_int(substr ($buf , $offset ));
565
- $offset += $len ;
561
+ ($len , $type ) = parse_int(substr ($buf , $offset ));
562
+
563
+ if (!defined $len ) {
564
+ $self -> {frames_incomplete }[$stream ]{buf } = $buf ;
565
+ next ;
566
+ }
567
+
568
+ $offset += $len ;
566
569
567
- $self -> {frames_incomplete }[$stream ]{type } = $type ;
568
- $self -> {frames_incomplete }[$stream ]{length } = $length ;
569
- $self -> {frames_incomplete }[$stream ]{offset } = $offset ;
570
+ ($len , $length ) = parse_int(substr ($buf , $offset ));
571
+
572
+ if (!defined $len ) {
573
+ $self -> {frames_incomplete }[$stream ]{buf } = $buf ;
574
+ next ;
570
575
}
571
576
577
+ $offset += $len ;
578
+
579
+ $self -> {frames_incomplete }[$stream ]{type } = $type ;
580
+ $self -> {frames_incomplete }[$stream ]{length } = $length ;
581
+ $self -> {frames_incomplete }[$stream ]{offset } = $offset ;
582
+
572
583
if (length ($buf ) < $self -> {frames_incomplete }[$stream ]{length }
573
584
+ $self -> {frames_incomplete }[$stream ]{offset })
574
585
{
@@ -1987,8 +1998,12 @@ sub build_stream {
1987
1998
1988
1999
sub parse_int {
1989
2000
my ($buf ) = @_ ;
2001
+ return undef if length ($buf ) < 1;
2002
+
1990
2003
my $val = unpack (" C" , substr ($buf , 0, 1));
1991
2004
my $len = my $plen = 1 << ($val >> 6);
2005
+ return undef if length ($buf ) < $len ;
2006
+
1992
2007
$val = $val & 0x3f;
1993
2008
while (--$len ) {
1994
2009
$val = ($val << 8) + unpack (" C" , substr ($buf , $plen - $len , 1))
0 commit comments