summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Brant <dbrant@wikimedia.org>2016-01-31 21:27:50 -0500
committerDmitry Brant <dbrant@wikimedia.org>2016-01-31 21:27:50 -0500
commit7966d8555fc0669e2ec965ab4ff4a1d190aca5ec (patch)
tree71e05ecb23b1bfb1c8ab070c892f4d01d8c5de4c
parenta74c4541751f03d5cebc0129c6ebcd0e5d7908f4 (diff)
Finalized .BPG support.
-rw-r--r--.gitignore33
-rw-r--r--src/file_bpg.c24
2 files changed, 15 insertions, 42 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index bce39f2..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,33 +0,0 @@
-# Generated files
-*.o
-*.in
-*.8
-config/
-config.*
-Makefile
-.deps/
-
-/autom4te.cache
-/autoscan.log
-/autoscan-*.log
-/aclocal.m4
-/compile
-/configure
-/configure.scan
-/depcomp
-/install-sh
-/missing
-/stamp-h1
-
-/linux/testdisk.spec
-/src/fidentify
-/src/moc_qphotorec.cpp
-/src/photorec
-/src/photorec.ses
-/src/qphotorec
-/src/rcc_qphotorec.cpp
-/src/testdisk
-
-# OS specific files
-*~
-.DS_Store
diff --git a/src/file_bpg.c b/src/file_bpg.c
index a74e303..9312652 100644
--- a/src/file_bpg.c
+++ b/src/file_bpg.c
@@ -4,6 +4,9 @@
Copyright (C) 1998-2007 Christophe GRENIER <grenier@cgsecurity.org>
Copyright (C) 2016 Dmitry Brant <me@dmitrybrant.com>
+
+ BPG specification can be found at:
+ http://bellard.org/bpg/bpg_spec.txt
This software is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,18 +34,20 @@
#include "types.h"
#include "filegen.h"
+#define MAX_BPG_SIZE 0x800000
+
static void register_header_check_bpg(file_stat_t *file_stat);
const file_hint_t file_hint_bpg= {
.extension="bpg",
.description="Better Portable Graphics image",
- .max_filesize=PHOTOREC_MAX_FILE_SIZE,
+ .max_filesize=MAX_BPG_SIZE,
.recover=1,
.enable_by_default=1,
.register_header_check=&register_header_check_bpg
};
-static int getue32(const unsigned char *buffer, const unsigned int buffer_size, unsigned int *buf_ptr)
+static unsigned int getue32(const unsigned char *buffer, const unsigned int buffer_size, unsigned int *buf_ptr)
{
unsigned int value = 0;
unsigned int b;
@@ -66,14 +71,15 @@ static int header_check_bpg(const unsigned char *buffer, const unsigned int buff
{
unsigned int buf_ptr = 6;
// get image width, and throw it away
- int width = getue32(buffer, buffer_size, &buf_ptr);
- printf(">>>> width...%d\n", width);
+ unsigned int width = getue32(buffer, buffer_size, &buf_ptr);
// get image height, and throw it away
- int height = getue32(buffer, buffer_size, &buf_ptr);
- printf(">>>> height...%d\n", height);
- int size = getue32(buffer, buffer_size, &buf_ptr);
- printf(">>>> size...%d\n", size);
-
+ unsigned int height = getue32(buffer, buffer_size, &buf_ptr);
+ unsigned int size = getue32(buffer, buffer_size, &buf_ptr);
+ if (size == 0) {
+ size = MAX_BPG_SIZE;
+ } else {
+ size += buf_ptr;
+ }
reset_file_recovery(file_recovery_new);
file_recovery_new->calculated_file_size=size;
file_recovery_new->data_check=&data_check_size;