~ubuntu-branches/ubuntu/hardy/clamav/hardy-backports

« back to all changes in this revision

Viewing changes to libclamav/pdf.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes, Stephen Gran, Michael Meskes, Michael Tautschnig
  • Date: 2008-11-29 12:15:34 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (4.1.3 sid) (0.5.4 karmic)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20081129121534-8sbpoy6kr01ox2eo
[ Stephen Gran ]
* New upstream version

[ Michael Meskes ]
* Removed unused debconf templates and unfuzzied all translations.

[ Michael Tautschnig ]
* Removed --unzip from clampipe script (closes: #506055)
* Moved clamav-milter specific stuff from its specific README.Debian to
  clamav-global one.
* Sync start of clamav-milter with clamav-daemon when clamav-daemon is being
  upgraded (closes: #309067)
* The TemporaryDirectory option has been added long ago, no need for hacks
  via clamav-daemon.default anymore (closes: #253080)

Show diffs side-by-side

added added

removed removed

Lines of Context:
278
278
                                         *      supported
279
279
                                         */
280
280
                                        if((bytesleft > 11) && strncmp(q, " 0 R", 4) == 0) {
281
 
                                                const char *r;
 
281
                                                const char *r, *nq;
 
282
                                                int opt_failed = 0;
 
283
                                                size_t len;
282
284
                                                char b[14];
283
285
 
284
286
                                                q += 4;
285
287
                                                cli_dbgmsg("cli_pdf: Length is in indirect obj %lu\n",
286
288
                                                        length);
287
289
                                                snprintf(b, sizeof(b),
288
 
                                                        "\n%lu 0 obj", length);
 
290
                                                        "%lu 0 obj", length);
289
291
                                                length = (unsigned long)strlen(b);
290
 
                                                r = cli_pmemstr(buf, size, b, length);
291
 
                                                if(r == NULL) {
292
 
                                                        b[0] = '\r';
293
 
                                                        r = cli_pmemstr(buf, size, b, length);
294
 
                                                }
 
292
                                                /* optimization: assume objects
 
293
                                                 * are sequential */
 
294
                                                nq = q;
 
295
                                                len = buf + size - q;
 
296
                                                do {
 
297
                                                        r = cli_pmemstr(nq, len, b, length);
 
298
                                                        if (r > nq) {
 
299
                                                                const char x = *(r-1);
 
300
                                                                if (x == '\n' || x=='\r') {
 
301
                                                                        --r;
 
302
                                                                        break;
 
303
                                                                }
 
304
                                                        }
 
305
                                                        if (r) {
 
306
                                                                len -= r+1-nq;
 
307
                                                                nq = r + 1;
 
308
                                                        } else if (!opt_failed) {
 
309
                                                                /* we failed optimized match,
 
310
                                                                 * try matching from the beginning
 
311
                                                                 */
 
312
                                                                len = q - buf;
 
313
                                                                r = nq = buf;
 
314
                                                                /* prevent
 
315
                                                                 * infloop */
 
316
                                                                opt_failed = 1;
 
317
                                                        }
 
318
                                                } while (r);
295
319
                                                if(r) {
296
320
                                                        r += length - 1;
297
321
                                                        r = pdf_nextobject(r, bytesleft - (r - q));
401
425
                calculated_streamlen = (int)(streamend - streamstart);
402
426
                real_streamlen = length;
403
427
 
404
 
                if(calculated_streamlen != real_streamlen)
405
 
                        cli_dbgmsg("cli_pdf: Incorrect Length field in file attempting to recover\n");
406
 
 
407
428
                cli_dbgmsg("cli_pdf: length %lu, calculated_streamlen %lu isFlate %d isASCII85 %d\n",
408
429
                        length, calculated_streamlen,
409
430
                        is_flatedecode, is_ascii85decode);
410
431
 
 
432
                if(calculated_streamlen != real_streamlen) {
 
433
                        cli_dbgmsg("cli_pdf: Incorrect Length field in file attempting to recover\n");
 
434
                        if(real_streamlen > calculated_streamlen)
 
435
                                real_streamlen = calculated_streamlen;
 
436
                }
411
437
#if     0
412
438
                /* FIXME: this isn't right... */
413
439
                if(length)
617
643
 
618
644
        zstat = inflateInit(&stream);
619
645
        if(zstat != Z_OK) {
620
 
                cli_warnmsg("cli_pdf: inflateInit failed");
 
646
                cli_warnmsg("cli_pdf: inflateInit failed\n");
621
647
                return CL_EMEM;
622
648
        }
623
649