diff options
author | robi <robi> | 2011-11-29 17:41:19 +0000 |
---|---|---|
committer | robi <robi> | 2011-11-29 17:41:19 +0000 |
commit | fbfcb5772f05bb171cb758e6c778da5260f5cb03 (patch) | |
tree | c0cc425c5f54eff053562233f46378477baecdab | |
parent | 55fcea964785643e046b2a2eaf5eb29dda65c418 (diff) |
potential for endless loop
-rw-r--r-- | src/file_type.c | 5 | ||||
-rw-r--r-- | src/magic_block_scan.c | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/file_type.c b/src/file_type.c index 1efaa65..521476e 100644 --- a/src/file_type.c +++ b/src/file_type.c @@ -542,6 +542,8 @@ static int follow_zip(unsigned char *buf, __u16 blockcount, __u32 *offset, __u32 __u16 *p_16; __u32 *p_32; + if (i == end) + end++; while ((ret == 1 )&& ( i < end )){ if (priv->flag){ while ((i < end) && (!((buf[i] == 0x50) && (buf[i+1] ==0x4B) && (buf[i+2] ==0x07)&& (buf[i+3] ==0x08)))){ @@ -2229,7 +2231,8 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3 int tmp_slot,slot = 0; __u16 tmp_flag,crc,crc_d ; - + if (end == f_offset) + end++; while ((ret ==1) && (f_offset < end)){ switch (priv->flag & 0x07){ case 0 : //header diff --git a/src/magic_block_scan.c b/src/magic_block_scan.c index 61ac668..4a9d620 100644 --- a/src/magic_block_scan.c +++ b/src/magic_block_scan.c @@ -759,7 +759,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_ } else { if (strstr(magic_buf,"message/")){ - retval |= ( M_MESSAGE | M_CLASS_2); + retval |= ( M_MESSAGE | M_CLASS_1); goto out; } else{ @@ -1255,7 +1255,7 @@ static int check_extent_len(struct ext3_extent_header *header, struct extent_are continue; } for (i = 0; ((! ret) && (i< ext2fs_le16_to_cpu(extent->ee_len))); i++){ - if (ext2fs_test_block_bitmap( bmap,ext2fs_le32_to_cpu(extent->ee_start) + i )) + if (ext2fs_test_block_bitmap(bmap,ext2fs_le32_to_cpu(extent->ee_start)+i)&&(!(d_bmap,ext2fs_le32_to_cpu(extent->ee_start)+i))) ret = 4; } if (!ret){ @@ -1405,7 +1405,7 @@ while (ds_retval){ first_b = ea->start_b; if(( ext2fs_test_block_bitmap( bmap,first_b)) || (io_channel_read_blk (current_fs->io,first_b - 1,9,tmp_buf ))){ - fprintf(stderr,"!ERROR: while read block %10lu\n",first_b); + fprintf(stderr,"Warning: block %10lu can not read or is allocated\n",first_b); //FIXME ERROR goto ? } else{ @@ -1453,7 +1453,7 @@ while (ds_retval){ first_b = ea->start_b; if(( ext2fs_test_block_bitmap( bmap,first_b)) || (io_channel_read_blk (current_fs->io,first_b-1 ,9,tmp_buf ))){ - fprintf(stderr,"!ERROR: while read block %10lu\n",first_b); + fprintf(stderr,"Warning: block %10lu can not read or is allocated\n",first_b); //FIXME ERROR goto ? } else{ @@ -1530,11 +1530,11 @@ newloop: add_file_data(file_data, blk[0]+i+j, scan ,&follow); (ea->len)++; } - blk[0] += i+j; + blk[0] += i+j; count = get_range(blk ,ds_bmap,buf, &border); ret = 1; while (ret && (!(file_data->scantype & (DATA_READY | DATA_BREAK)))){ - file_data->buf_length = count; + file_data->buf_length = (!follow) ? (count+1) : count; ret = file_data->func(buf, &size ,scan ,3 , file_data); if (ret){ if (((!file_data->buf_length)&& (!(file_data->scantype & (DATA_READY))))|| ((ret == 3) && (file_data->scantype & H_F_Carving))){ |