* @file ole.c
* @author Alex Ott, Victor B Wagner
* @date Wed Jun 11 12:33:01 2003
- * Version: $Id: ole.c,v 1.1 2006-02-24 17:44:06 vitus Exp $
+ * Version: $Id: ole.c,v 1.2 2006-02-25 15:28:14 vitus Exp $
* Copyright: Victor B Wagner, 1996-2003 Alex Ott, 2003
*
* @brief Parsing structure of MS Office compound document
unsigned char *properties=NULL;
long int fileLength=0;
-static unsigned 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
if ( ret != BBD_BLOCK_SIZE ) {
return NULL;
}
- if (strncmp(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);
/* Find Root Entry */
while((tEntry=(oleEntry*)ole_readdir(newfile)) != NULL) {
- if (!tEntry->name[0]||strcmp(tEntry->name,"Root Entry") == 0) {
+ if (tEntry->type == oleRootDir ) {
rootEntry=tEntry;
break;
}
propCurNumber = 0;
fseek(newfile, 0, SEEK_SET);
if (!rootEntry) {
- fprintf(stderr,"Cannot find root entry in this file!\n");
- ole_finish();
+ fprintf(stderr,"Broken OLE structure. Cannot find root entry in this file!\n"); ole_finish();
return NULL;
}
return newfile;
(e->startBlock <=
fileLength/(e->isBigBlock ? sectorSize : shortSectorSize))) {
if((e->blocks=malloc(chainMaxLen*sizeof(long int))) == NULL ) {
+ free(e);
return NULL;
}
while(1) {
+ if(chainCurrent < 0 ||
+ chainCurrent >= (
+ e->isBigBlock ?
+ ((bbdNumBlocks*sectorSize)/4) :
+ ((sbdNumber*shortSectorSize)/4)
+ ) ||
+ (e->numOfBlocks >
+ e->length/(
+ e->isBigBlock ?
+ sectorSize :
+ shortSectorSize
+ )
+ )
+ ) {
+/* fprintf(stderr, "chain End=%ld\n", chainCurrent); */
+ break;
+ }
/* fprintf(stderr, "chainCurrent=%ld\n", chainCurrent); */
e->blocks[e->numOfBlocks++] = chainCurrent;
if (e->numOfBlocks >= chainMaxLen) {
} else {
chainCurrent=-1;
}
- if(chainCurrent <= 0 ||
- chainCurrent >= ( e->isBigBlock ?
- ((bbdNumBlocks*sectorSize)/4)
- : ((sbdNumber*shortSectorSize)/4) ) ||
- (e->numOfBlocks >
- e->length/(e->isBigBlock ? sectorSize : shortSectorSize))) {
-/* fprintf(stderr, "chain End=%ld\n", chainCurrent); */
- break;
- }
}
}