summaryrefslogtreecommitdiffstats
path: root/src/file_gho.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-05-11 09:25:39 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-05-11 09:25:39 +0200
commite1ca4010307fb53d83c5036f6c8269eb9066c928 (patch)
tree79a9547954c70be7ddc88324990d60a163ffb16d /src/file_gho.c
parentf63304053aa32515e4853c2472fb785bcda0307c (diff)
remove always-true memcmp
Diffstat (limited to 'src/file_gho.c')
-rw-r--r--src/file_gho.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/file_gho.c b/src/file_gho.c
index 4e235d0..9c94609 100644
--- a/src/file_gho.c
+++ b/src/file_gho.c
@@ -30,9 +30,7 @@
#include "types.h"
#include "filegen.h"
-
static void register_header_check_gho(file_stat_t *file_stat);
-static int header_check_db(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 file_hint_t file_hint_gho= {
.extension="gho",
@@ -44,25 +42,18 @@ const file_hint_t file_hint_gho= {
.register_header_check=&register_header_check_gho
};
-
-static const unsigned char gho_header[3]= { 0xfe, 0xef, 0x01 };
-static const unsigned char gho_header_next[8]= { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static void register_header_check_gho(file_stat_t *file_stat)
+static int header_check_db(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)
{
- register_header_check(0, gho_header,sizeof(gho_header), &header_check_db, file_stat);
+ static const unsigned char gho_header_next[8]= { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ if(memcmp (buffer+8, gho_header_next, sizeof(gho_header_next))!=0)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_gho.extension;
+ return 1;
}
-static int header_check_db(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)
+static void register_header_check_gho(file_stat_t *file_stat)
{
- if(memcmp (buffer, gho_header, sizeof(gho_header))==0 &&
- memcmp (buffer+8, gho_header_next, sizeof(gho_header_next))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_gho.extension;
- return 1;
- }
- return 0;
+ static const unsigned char gho_header[3]= { 0xfe, 0xef, 0x01 };
+ register_header_check(0, gho_header,sizeof(gho_header), &header_check_db, file_stat);
}
-
-