summaryrefslogtreecommitdiffstats
path: root/src/file_png.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2017-09-12 13:16:15 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2017-09-12 13:16:15 +0200
commitb75c2fca2a39cea956efff127c345c00e99486f0 (patch)
treede23d458cffe11c9568621c64b4815291fe3f0ba /src/file_png.c
parent65543b032a3f3978f46add944c050d30e2d1a400 (diff)
PhotoRec: avoid potential endless loops
Diffstat (limited to 'src/file_png.c')
-rw-r--r--src/file_png.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/file_png.c b/src/file_png.c
index e79f4cd..31b8a69 100644
--- a/src/file_png.c
+++ b/src/file_png.c
@@ -115,7 +115,7 @@ static void file_check_png(file_recovery_t *fr)
fr->file_size=0;
return ;
}
- fr->file_size+=12 + be32(chunk->length);
+ fr->file_size+=(uint64_t)12 + be32(chunk->length);
if(memcmp(&buffer[4], "IEND", 4)==0)
return ;
}
@@ -156,7 +156,7 @@ static data_check_t data_check_mng(const unsigned char *buffer, const unsigned i
const struct png_chunk *chunk=(const struct png_chunk *)&buffer[i];
if(memcmp(&buffer[i+4], mng_footer, sizeof(mng_footer))==0)
{
- file_recovery->calculated_file_size+=12 + be32(chunk->length);
+ file_recovery->calculated_file_size+=(uint64_t)12 + be32(chunk->length);
return DC_STOP;
}
if( !((isupper(buffer[i+4]) || islower(buffer[i+4])) &&
@@ -168,7 +168,7 @@ static data_check_t data_check_mng(const unsigned char *buffer, const unsigned i
return DC_ERROR;
}
file_recovery->offset_ok=file_recovery->calculated_file_size+7;
- file_recovery->calculated_file_size+=12 + be32(chunk->length);
+ file_recovery->calculated_file_size+=(uint64_t)12 + be32(chunk->length);
}
return DC_CONTINUE;
}
@@ -182,7 +182,7 @@ static data_check_t data_check_png(const unsigned char *buffer, const unsigned i
const struct png_chunk *chunk=(const struct png_chunk *)&buffer[i];
if(memcmp(&buffer[i+4], "IEND", 4)==0)
{
- file_recovery->calculated_file_size+=12 + be32(chunk->length);
+ file_recovery->calculated_file_size+=(uint64_t)12 + be32(chunk->length);
return DC_STOP;
}
// PNG chunk code
@@ -197,7 +197,7 @@ static data_check_t data_check_png(const unsigned char *buffer, const unsigned i
return DC_ERROR;
}
file_recovery->offset_ok=file_recovery->calculated_file_size+7;
- file_recovery->calculated_file_size+=12 + be32(chunk->length);
+ file_recovery->calculated_file_size+=(uint64_t)12 + be32(chunk->length);
}
return DC_CONTINUE;
}