X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=oss%2Fcatdoc.git;a=blobdiff_plain;f=src%2Fole.c;h=805d8c716c9694bba2a4afc7c7045bb00953a0e4;hp=5267dfa29f1b0bb0e000bbb0a0cf417e8fac0ca7;hb=704c53839728067bb54c9c570916b77008388a23;hpb=a79f2377217c571396074fccf360e01032cd77bf diff --git a/src/ole.c b/src/ole.c index 5267dfa..805d8c7 100644 --- 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<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) { @@ -353,15 +374,6 @@ FILE *ole_readdir(FILE *f) { } 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; - } } }