fixed infinity loop caused by damaged pcapng file with total block length 0 and cpalen 0
@@ -5459,28 +5459,26 @@ while(1)
pcapngbh->block_type = byte_swap_32(pcapngbh->block_type);
pcapngbh->total_length = byte_swap_32(pcapngbh->total_length);
}
- resseek = lseek(fd, aktseek, SEEK_SET);
- if(resseek < 0)
+ if(pcapngbh->total_length > (2 *MAXPACPSNAPLEN))
{
pcapreaderrors++;
- printf("failed to set file pointer\n");
+ printf("failed to read pcapng header block\n");
break;
}
-
- if(pcapngbh->total_length > (2 *MAXPACPSNAPLEN))
+ resseek = lseek(fd, aktseek, SEEK_SET);
+ if(resseek < 0)
{
pcapreaderrors++;
- printf("failed to read pcapng header block\n");
+ printf("failed to set file pointer\n");
break;
}
res = read(fd, &pcpngblock, pcapngbh->total_length);
- if(res != pcapngbh->total_length)
+ if((res == 0) || (res != pcapngbh->total_length))
{
pcapreaderrors++;
printf("failed to read pcapng header block\n");
break;
}
-
if(pcapngbh->block_type == PCAPNGBLOCKTYPE)
{
pcapngshb = (section_header_block_t*) pcpngblock;
