diff --git a/src/file_exe.c b/src/file_exe.c index fab7e18f..819cc695 100644 --- a/src/file_exe.c +++ b/src/file_exe.c @@ -119,7 +119,10 @@ static int header_check_exe(const unsigned char *buffer, const unsigned int buff uint64_t sum=0; const struct pe_image_section_hdr *pe_image_section=(const struct pe_image_section_hdr*) ((const unsigned char*)pe_hdr + sizeof(struct pe_image_file_hdr) + le16(pe_hdr->SizeOfOptionalHeader)); - for(i=0;iNumberOfSections) && (const unsigned char*)pe_image_section < buffer+buffer_size;i++,pe_image_section++) + for(i=0; + iNumberOfSections) && + (const unsigned char*)(pe_image_section+1) <= buffer+buffer_size; + i++,pe_image_section++) { if(le32(pe_image_section->SizeOfRawData)>0) { diff --git a/src/file_fits.c b/src/file_fits.c index a82e4386..606772fd 100644 --- a/src/file_fits.c +++ b/src/file_fits.c @@ -71,7 +71,7 @@ static uint64_t fits_info(const unsigned char *buffer, const unsigned int buffer uint64_t naxis_size=1; unsigned int i=*i_pointer; /* Header is composed of 80 character fixed-length strings */ - for(; i255) return 2; diff --git a/src/file_mp3.c b/src/file_mp3.c index cddcbb02..9cde9476 100644 --- a/src/file_mp3.c +++ b/src/file_mp3.c @@ -367,7 +367,9 @@ static data_check_t data_check_mp3(const unsigned char *buffer, const unsigned i static unsigned int pos_in_mem(const unsigned char *haystack, const unsigned int haystack_size, const unsigned char *needle, const unsigned int needle_size) { unsigned int i; - for(i=0;iextension="avi"; /* Is it a raw avi stream with Data Binary chunks ? */ - if(size + 4 < buffer_size && + if(size < buffer_size - 4 && memcmp(&buffer[size - sizeof(list_movi)], &list_movi, sizeof(list_movi)) ==0 && buffer[size+2]=='d' && buffer[size+3]=='b') diff --git a/src/file_zip.c b/src/file_zip.c index 68f24313..a9dfe925 100644 --- a/src/file_zip.c +++ b/src/file_zip.c @@ -880,7 +880,9 @@ static int header_check_winzip(const unsigned char *buffer, const unsigned int b static unsigned int pos_in_mem(const unsigned char *haystack, const unsigned int haystack_size, const unsigned char *needle, const unsigned int needle_size) { unsigned int i; - for(i=0;i