summaryrefslogtreecommitdiffstats
path: root/src/file_lnk.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-05-21 09:01:25 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2010-05-21 09:01:25 +0200
commitd5bd548dee9dbf988574633994bd803865810f3f (patch)
tree87554081721119b1969da27d26e2f31b650bf077 /src/file_lnk.c
parente9d4598c2bed3a653c83f2fe5c44b52cb4835dc0 (diff)
PhotoRec: stricter check for .lnk
Diffstat (limited to 'src/file_lnk.c')
-rw-r--r--src/file_lnk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/file_lnk.c b/src/file_lnk.c
index 72c9718..d050237 100644
--- a/src/file_lnk.c
+++ b/src/file_lnk.c
@@ -51,6 +51,8 @@ static const unsigned char lnk_header[20]= {
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 /* GUID */
};
+static const unsigned char lnk_reserved[10]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
struct lnk_header_s {
uint32_t magic; /* 0h Always 0000004Ch ā€˜Lā€™ */
char guid[16]; /* 4h GUID of shortcut files */
@@ -86,7 +88,8 @@ static void register_header_check_lnk(file_stat_t *file_stat)
static int header_check_lnk(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)
{
- if(memcmp(buffer,lnk_header,sizeof(lnk_header))==0)
+ if(memcmp(buffer, lnk_header, sizeof(lnk_header))==0 &&
+ memcmp(&buffer[0x42], lnk_reserved, sizeof(lnk_reserved))==0)
{
const struct lnk_header_s* lnk_head=(const struct lnk_header_s*)buffer;
const uint32_t flags=le32(lnk_head->flags);