Add detection of ZIP-archive and report that this type of file (i.e. OOXML or OpenDoc...
authorVictor Wagner <vitus@wagner.pp.ru>
Tue, 26 Apr 2016 15:38:02 +0000 (18:38 +0300)
committerVictor Wagner <vitus@wagner.pp.ru>
Tue, 26 Apr 2016 15:38:02 +0000 (18:38 +0300)
src/analyze.c
src/ole.c

index bebcbef63027a793bb055fe9db1c9e622095ca70..1ac927ed722f057dcb96a958ba1282eac09e284a 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "catdoc.h"
-char ole_sign[]={0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1,0};
+extern char ole_sign[], zip_sign[]; /* from ole.c */
 char rtf_sign[]="{\\rtf";
 char old_word_sign[]={0xdb,0xa5,0};
 char write_sign[]={0x31,0xBE,0};
@@ -45,6 +45,10 @@ int analyze_format(FILE *f) {
                return process_file(f,LONG_MAX);
        } else if (strncmp((char *)&buffer,rtf_sign,4)==0) {
                return parse_rtf(f);
+       } else if (strncmp((char *)&buffer, zip_sign,4) == 0) {
+               fprintf(stderr,"This file looks like ZIP archive or Office 2007 "
+               "or later file.\nNot supported by catdoc\n");
+               exit(1);
        } else if (strncmp((char *)&buffer,old_word_sign,2)==0) {
           fread(buffer+4,1,124,f);     
           return parse_word_header(buffer,f,128,0);
index 68fade81abedf004c6da3715670cabca1f1bab13..805d8c716c9694bba2a4afc7c7045bb00953a0e4 100644 (file)
--- a/src/ole.c
+++ b/src/ole.c
@@ -37,8 +37,8 @@ long propCurNumber, propLen, propNumber, propStart;
 unsigned char *properties=NULL;
 long int fileLength=0;
 
-static char ole_sign[]={0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1,0};
-
+char ole_sign[]={0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1,0};
+char zip_sign[]="PK\003\004";
 
 /** 
  * Initializes ole structure
@@ -97,7 +97,10 @@ FILE* ole_init(FILE *f, void *buffer, size_t bufSize)  {
        if ( ret != BBD_BLOCK_SIZE ) {
                return NULL;
        }
-       if (strncmp((char *)&oleBuf,ole_sign,8) != 0) {
+       if (strncmp((char *)&oleBuf,zip_sign,4) == 0) {
+               fprintf(stderr,"Looks like ZIP archive or Office 2007 or later. Not supported\n");
+               return NULL;
+       } else if (strncmp((char *)&oleBuf,ole_sign,8) != 0) {
                return NULL;
        }
        sectorSize = 1<<getshort(oleBuf,0x1e);