#19 To Filter out Corrupted Documents Apriory

closed-fixed
Dom Lachowicz
None
5
2004-10-09
2004-10-07
Sudar
No

When wvWare is exposed to corrupted documents, the
behaviour is unpredicatable. sometimes, it crashes.
sometimes it consumes a lot of memory and sometimes it
loops with 100% cpu. A patch is made to filter some of
the corrupted documents before it gets to the core of
the structured file.

in the source, wv\wvParse.c

int wvInitParser (wvParseStruct * ps, char *path)
{
...
...
...
wvGetFIB (&ps->fib, ps->mainfd);

ps->tablefd = wvWhichTableStream (&ps->fib, ps);

///////// PATCH /////////
// Check the validity of the table stream.
if (ps->tablefd == NULL)
{
wvOLEFree(ps);
wvError(("Data Stream Corrupt or Not Readable\n"));
return (-1);
}

// When the data stream is null, it is highly probable
// that the document is corrupt
if (ps->data == NULL)
{
// checking for the validity of the Clx data
// from the table stream
if (wvStream_goto(ps->tablefd, ps->fib.fcClx)==-1)
{
wvOLEFree(ps);
wvError(("Data Stream Corrupt or Not Readable\n"));
return (-1);
}
wvStream_rewind(ps->tablefd);
// Reset the stream to the begining
} // SIS
///////// PATCH /////////

ret = wvQuerySupported (&ps->fib, &reason);

if ((ret & 0x7fff) != WORD8)
ps->data = ps->mainfd;
...
...

ret=0;
return ret;
}

This patch filters many corrupted documents to avoid a
possible damage to the application.

Discussion

  • Sudar
    Sudar
    2004-10-07

    Logged In: YES
    user_id=1133964

    Please evalate and add this patch to the system.

     
  • Sudar
    Sudar
    2004-10-07

    • assigned_to: nobody --> cinamod
    • status: open --> open-remind
     
  • Dom Lachowicz
    Dom Lachowicz
    2004-10-07

    Logged In: YES
    user_id=69417

    please attach a patch with the output of 'cvs diff -u'. thanks.

     
  • Dom Lachowicz
    Dom Lachowicz
    2004-10-09

    • status: open-remind --> closed-fixed
     
  • Dom Lachowicz
    Dom Lachowicz
    2004-10-09

    Logged In: YES
    user_id=69417

    thanks.

     
  • Sudar
    Sudar
    2004-10-11

    The Patch (cvs diff -u output)

     
    Attachments
  • Sudar
    Sudar
    2004-10-11

    Logged In: YES
    user_id=1133964

    Index: wvparse.c

    =====================
    RCS file: /cvsroot/wvware/wv/wvparse.c,v
    retrieving revision 1.13
    diff -u -r1.13 wvparse.c
    --- wvparse.c 1 Dec 2002 11:23:46 -0000 1.13
    +++ wvparse.c 11 Oct 2004 07:25:49 -0000
    @@ -100,6 +100,28 @@
    wvGetFIB (&ps->fib, ps->mainfd);

    ps->tablefd = wvWhichTableStream (&ps->fib, ps);
    + // SIS (radusdirect@yahoo.com)
    + // Check the validity of the table stream.
    + if (ps->tablefd == NULL)
    + {
    + wvOLEFree(ps);
    + wvError(("Data Stream Corrupt or Not
    Readable\n"));
    + return (-1);
    + }
    +
    + // When the data stream is null, it is highly probable
    + // that the document is corrupt
    + if (ps->data == NULL)
    + {
    + // checking for the validity of the Clx data
    from the table stream
    + if (wvStream_goto(ps->tablefd, ps-
    >fib.fcClx)==-1)
    + {
    + wvOLEFree(ps);
    + wvError(("Data Stream Corrupt or
    Not Readable\n"));
    + return (-1);
    + }
    + wvStream_rewind(ps->tablefd); // Reset
    the stream to the begining
    + } // SIS

    ret = wvQuerySupported (&ps->fib, &reason);