summaryrefslogtreecommitdiffstats
path: root/src/file_txt.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-23 15:39:32 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-23 15:39:32 +0100
commit700066869becbfa31915babe08519a4f96cbe50e (patch)
tree95584e6b39a3c37639e7a3f976bc584d1c7e3b8c /src/file_txt.c
parent06bd7ec9e621af6ee959f0a0c3c8964b8e698146 (diff)
PhotoRec: better check for STL in ascii format
Diffstat (limited to 'src/file_txt.c')
-rw-r--r--src/file_txt.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/file_txt.c b/src/file_txt.c
index 78dda6d..918b4f4 100644
--- a/src/file_txt.c
+++ b/src/file_txt.c
@@ -1127,20 +1127,16 @@ static int header_check_smil(const unsigned char *buffer, const unsigned int buf
static int header_check_stl(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 const unsigned char spaces[16]={
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
- if(memcmp(buffer+0x40, spaces, sizeof(spaces))!=0)
- {
- /* StereoLithography - STL Ascii format
- * http://www.ennex.com/~fabbers/StL.asp */
- reset_file_recovery(file_recovery_new);
- file_recovery_new->data_check=&data_check_txt;
- file_recovery_new->file_check=&file_check_size;
- file_recovery_new->extension="stl";
- return 1;
- }
- return 0;
+ const unsigned int buffer_size_test=(buffer_size < 512? buffer_size : 512);
+ if(td_memmem(buffer, buffer_size_test, "facet normal", 12)==NULL)
+ return 0;
+ /* StereoLithography - STL Ascii format
+ * http://www.ennex.com/~fabbers/StL.asp */
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->data_check=&data_check_txt;
+ file_recovery_new->file_check=&file_check_size;
+ file_recovery_new->extension="stl";
+ return 1;
}
static void register_header_check_fasttxt(file_stat_t *file_stat)