summaryrefslogtreecommitdiffstats
path: root/src/file_dir.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-11-01 13:42:51 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-11-01 13:42:51 +0100
commitb58be737f078928b6e1dc3cabc77bec20b059ece (patch)
treefff7ad10fc6993a247d4b9d2cc88d00c466ed8de /src/file_dir.c
parent0bf23249bb4ea2bf930148bfd59a13342cdedd76 (diff)
new functions is_fat_directory() and fat_get_cluster_from_entry()
rename sectors() to fat_sectors()
Diffstat (limited to 'src/file_dir.c')
-rw-r--r--src/file_dir.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/file_dir.c b/src/file_dir.c
index fcd7c2f..a82788d 100644
--- a/src/file_dir.c
+++ b/src/file_dir.c
@@ -36,6 +36,7 @@
#include "fat.h"
#include "dir.h"
#include "fat_dir.h"
+#include "fat_common.h"
static void register_header_check_dir(file_stat_t *file_stat);
static int header_check_dir(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);
@@ -61,9 +62,9 @@ static void file_rename_fatdir(const char *old_filename)
return;
buffer_size=fread(buffer, 1, sizeof(buffer), file);
fclose(file);
- if(buffer_size<10)
+ if(buffer_size<32)
return;
- cluster=(buffer[0x15]<<24)|(buffer[0x14]<<16)|(buffer[0x1B]<<8)|buffer[0x1A];
+ cluster=fat_get_cluster_from_entry((const struct msdos_dir_entry *)&buffer[0]);
sprintf(buffer_cluster, "cluster_%u", cluster);
file_rename(old_filename, buffer_cluster, strlen(buffer_cluster), 0, NULL, 1);
}
@@ -78,7 +79,7 @@ static int data_check_fatdir(const unsigned char *buffer, const unsigned int buf
static int header_check_dir(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 msdos_dir_entry *de=(const struct msdos_dir_entry*)buffer;
- if(memcmp(&buffer[0x20],".. ",8+3)!=0)
+ if(!is_fat_directory(buffer))
return 0;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_dir.extension;