summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/file_abr.c6
-rw-r--r--src/file_exe.c2
-rw-r--r--src/file_gpg.c2
-rw-r--r--src/file_hdf.c8
-rw-r--r--src/file_indd.c2
-rw-r--r--src/file_mpg.c2
6 files changed, 12 insertions, 10 deletions
diff --git a/src/file_abr.c b/src/file_abr.c
index 29aef9a..5d07f92 100644
--- a/src/file_abr.c
+++ b/src/file_abr.c
@@ -27,6 +27,7 @@
#include <string.h>
#endif
#include <stdio.h>
+#include <assert.h>
#include "types.h"
#include "filegen.h"
#include "common.h"
@@ -65,8 +66,9 @@ static data_check_t data_check_abr(const unsigned char *buffer, const unsigned i
static int header_check_abr(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
const struct abr_header *hdr=(const struct abr_header*)&buffer[4];
- unsigned int i=4;
- while(i + 12 < buffer_size && i + 12 < 512)
+ uint64_t i=4;
+ assert(buffer_size >= 12);
+ while(i < buffer_size - 12 && i < 512 - 12)
{
const struct abr_header *h=(const struct abr_header*)&buffer[i];
if(memcmp(h->magic, "8BIM", 4)!=0)
diff --git a/src/file_exe.c b/src/file_exe.c
index e8f0332..1348db5 100644
--- a/src/file_exe.c
+++ b/src/file_exe.c
@@ -178,7 +178,7 @@ static int header_check_exe(const unsigned char *buffer, const unsigned int buff
if(le16(dos_hdr->bytes_in_last_block))
coff_offset-=512-le16(dos_hdr->bytes_in_last_block);
- if(coff_offset+1 < buffer_size &&
+ if(coff_offset < buffer_size-1 &&
buffer[coff_offset]==0x4c && buffer[coff_offset+1]==0x01)
{ /* COFF_I386MAGIC */
reset_file_recovery(file_recovery_new);
diff --git a/src/file_gpg.c b/src/file_gpg.c
index b1aadf0..387e168 100644
--- a/src/file_gpg.c
+++ b/src/file_gpg.c
@@ -410,9 +410,9 @@ static void file_check_gpg(file_recovery_t *file_recovery)
static int header_check_gpg(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
+ uint64_t i=0;
unsigned int packet_tag[16];
unsigned int nbr=0;
- unsigned int i=0;
int partial_body_length=0;
int stop=0;
memset(packet_tag, 0, sizeof(packet_tag));
diff --git a/src/file_hdf.c b/src/file_hdf.c
index 53b0260..378855c 100644
--- a/src/file_hdf.c
+++ b/src/file_hdf.c
@@ -65,8 +65,8 @@ struct dd_struct
static void file_check_hdf(file_recovery_t *file_recovery)
{
uint64_t file_size=0;
- unsigned int offset_old=4;
- unsigned int offset=4;
+ uint64_t offset_old;
+ uint64_t offset=4;
struct dd_struct *dd=(struct dd_struct *)MALLOC(sizeof(struct dd_struct)*65536);
do
{
@@ -96,8 +96,8 @@ static void file_check_hdf(file_recovery_t *file_recovery)
be16(p->tag), be16(p->ref), be32(p->offset), be32(p->length));
#endif
if((unsigned)be32(p->offset)!=(unsigned)(-1) &&
- file_size < (unsigned)be32(p->offset) + (unsigned)be32(p->length))
- file_size = (unsigned)be32(p->offset) + (unsigned)be32(p->length);
+ file_size < (uint64_t)be32(p->offset) + (uint64_t)be32(p->length))
+ file_size = (uint64_t)be32(p->offset) + (uint64_t)be32(p->length);
}
offset_old=offset;
offset=be32(ddh.next);
diff --git a/src/file_indd.c b/src/file_indd.c
index 0fcea43..5d16702 100644
--- a/src/file_indd.c
+++ b/src/file_indd.c
@@ -103,7 +103,7 @@ static void file_check_indd(file_recovery_t *file_recovery)
return ;
}
/* header + data + trailer */
- offset+=le32(hdr.fStreamLength)+2*sizeof(struct InDesignContigObjMarker);
+ offset+=(uint64_t)le32(hdr.fStreamLength)+2*sizeof(struct InDesignContigObjMarker);
} while(offset < file_size_org);
file_recovery->file_size=(offset+4096-1)/4096*4096;
if(file_recovery->file_size>file_size_org)
diff --git a/src/file_mpg.c b/src/file_mpg.c
index c0ca71b..03b61d3 100644
--- a/src/file_mpg.c
+++ b/src/file_mpg.c
@@ -42,7 +42,7 @@ const file_hint_t file_hint_mpg= {
.register_header_check=&register_header_check_mpg
};
-static int calculate_packet_size(const unsigned char *buffer)
+static unsigned int calculate_packet_size(const unsigned char *buffer)
{
/* http://dvd.sourceforge.net/dvdinfo/mpeghdrs.html */
if(buffer[0]!=0 || buffer[1]!=0 || buffer[2]!=1)