~ubuntu-branches/ubuntu/raring/clamav/raring

« back to all changes in this revision

Viewing changes to libclamav/pdf.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2008-09-05 17:25:34 UTC
  • mfrom: (0.35.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080905172534-yi3f8fkye1o7u1r3
* New upstream version (closes: #497662, #497773)
  - lots of new options for clamd.conf
  - fixes CVEs CVE-2008-3912, CVE-2008-3913, CVE-2008-3914, and
    CVE-2008-1389
* No longer supports --unzip option, so typo is gone (closes: #496276)
* Translations:
  - sv (thanks Martin Bagge <brother@bsnet.se>) (closes: #491760)

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
#endif
66
66
 
67
67
#ifdef  CL_DEBUG
68
 
/*#define       SAVE_TMP        /* Save the file being worked on in tmp */
 
68
/*#define       SAVE_TMP        
 
69
 *Save the file being worked on in tmp */
69
70
#endif
70
71
 
71
72
static  int     try_flatedecode(unsigned char *buf, off_t real_len, off_t calculated_len, int fout, cli_ctx *ctx);
391
392
                if(streamend <= streamstart) {
392
393
                        close(fout);
393
394
                        cli_dbgmsg("cli_pdf: Empty stream\n");
394
 
                        unlink(fullname);
 
395
                        if (cli_unlink(fullname)) {
 
396
                                rc = CL_EIO;
 
397
                                break;
 
398
                        }
395
399
                        continue;
396
400
                }
397
401
                calculated_streamlen = (int)(streamend - streamstart);
417
421
 
418
422
                        if(ret != CL_CLEAN) {
419
423
                                close(fout);
420
 
                                unlink(fullname);
 
424
                                if (cli_unlink(fullname)) {
 
425
                                        rc = CL_EIO;
 
426
                                        break;
 
427
                                }
421
428
                                continue;
422
429
                        }
423
430
 
425
432
 
426
433
                        if(tmpbuf == NULL) {
427
434
                                close(fout);
428
 
                                unlink(fullname);
 
435
                                if (cli_unlink(fullname)) {
 
436
                                        rc = CL_EIO;
 
437
                                        break;
 
438
                                }
429
439
                                continue;
430
440
                        }
431
441
 
434
444
                        if(ret == -1) {
435
445
                                free(tmpbuf);
436
446
                                close(fout);
437
 
                                unlink(fullname);
 
447
                                if (cli_unlink(fullname)) {
 
448
                                        rc = CL_EIO;
 
449
                                        break;
 
450
                                }
438
451
                                continue;
439
452
                        }
440
453
                        if(ret) {
446
459
                                if(t == NULL) {
447
460
                                        free(tmpbuf);
448
461
                                        close(fout);
449
 
                                        unlink(fullname);
 
462
                                        if (cli_unlink(fullname)) {
 
463
                                                rc = CL_EIO;
 
464
                                                break;
 
465
                                        }
450
466
                                        continue;
451
467
                                }
452
468
                                tmpbuf = t;
487
503
 
488
504
                                if(tableFind(md5table, md5str) >= 0) {
489
505
                                        cli_dbgmsg("cli_pdf: not scanning duplicate embedded file '%s'\n", fullname);
 
506
                                        ctx->scannedfiles++;
490
507
                                        close(fout);
491
 
                                        unlink(fullname);
 
508
                                        if (cli_unlink(fullname)) {
 
509
                                                rc = CL_EIO;
 
510
                                                break;
 
511
                                        }
492
512
                                        continue;
493
513
                                } else
494
514
                                        tableInsert(md5table, md5str, 1);
498
518
                        rc = cli_magic_scandesc(fout, ctx);
499
519
                }
500
520
                close(fout);
501
 
                if(!cli_leavetemps_flag) unlink(fullname);
 
521
                if(!cli_leavetemps_flag)
 
522
                        if (cli_unlink(fullname)) rc = CL_EIO;
502
523
                if(rc != CL_CLEAN) break;
503
524
        }
504
525
 
648
669
        }
649
670
                        
650
671
#ifdef  SAVE_TMP
651
 
        unlink(tmpfilename);
 
672
        if (cli_unlink(tmpfilename)) {
 
673
                inflateEnd(&stream);
 
674
                return CL_EIO;
 
675
        }
652
676
#endif
653
677
        inflateEnd(&stream);
654
678
        return CL_CLEAN;
837
861
}
838
862
#else   /*!HAVE_MMAP*/
839
863
 
840
 
#include <sys/types.h>
841
864
#include "clamav.h"
842
865
#include "others.h"
843
866
#include "pdf.h"