summaryrefslogtreecommitdiffstats
path: root/src/file_bpg.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-12-11 16:16:50 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2016-12-11 16:16:50 +0100
commit43e91c9258b99c82345951711831384ff9e5b593 (patch)
treef9d0a6189ff0bf7fc94cf996bb2ffae095b4eb3d /src/file_bpg.c
parent55761170960b5f77bd213faef76e27e6c035d7d3 (diff)
PhotoRec: check picture_width and picture_height in bpg picture
Diffstat (limited to 'src/file_bpg.c')
-rw-r--r--src/file_bpg.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/file_bpg.c b/src/file_bpg.c
index 737eeb9..bc16eb5 100644
--- a/src/file_bpg.c
+++ b/src/file_bpg.c
@@ -69,11 +69,13 @@ static unsigned int getue32(const unsigned char *buffer, const unsigned int buff
static int header_check_bpg(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)
{
unsigned int buf_ptr = 6;
- // get image width, and throw it away
- const unsigned int width = getue32(buffer, buffer_size, &buf_ptr);
- // get image height, and throw it away
- const unsigned int height = getue32(buffer, buffer_size, &buf_ptr);
+ // get image width
+ const unsigned int picture_width = getue32(buffer, buffer_size, &buf_ptr);
+ // get image height
+ const unsigned int picture_height = getue32(buffer, buffer_size, &buf_ptr);
unsigned int size = getue32(buffer, buffer_size, &buf_ptr);
+ if(picture_width==0 || picture_height==0)
+ return 0;
if (size == 0) {
size = MAX_BPG_SIZE;
} else {