~ubuntu-branches/ubuntu/dapper/clamav/dapper-updates

« back to all changes in this revision

Viewing changes to libclamav/nsis/nulsft.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Tautschnig, Michael Tautschnig
  • Date: 2009-03-25 16:02:18 UTC
  • mfrom: (0.12.1 upstream)
  • mto: (12.1.9 dapper-security)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20090325160218-forpco6d0ghp48br
Tags: 0.95+dfsg-1
[ Michael Tautschnig ]
* New upstream version, fixes:
  - License incompatibility with libgmp (closes: #512776)
  - wrong claim about all interception message methods (closes: #438455)
  - clamdscan fails to connect to clamd (closes: #515798)
  - clamav-milter dies after email scanning (sparc64) (closes: #339590)
  - VERSION reports wrong database version (closes: #323803)
  - memory footprint skyrockets (closes: #420391)
  - Virus not detected in RAR-archive inside email (closes: #484642)
  - clamav-milter ignores whitelist file (closes: #520353)
  - clamav-milter won't start when both local and tcp socket are in use 
    (closes: #505852)
  - ERROR: Can't find any clamd server (closes: #435007)
  - clamd: random SIGABRT (closes: #512720)
* Removed configure options that aren't supported anymore (--with-sendmail,
  --with-tcpwrappers, --with-dns)
* Bumped Standards-Version to 3.8.1 (added mkdir calls to ensure
  /var/run/clamav exists)
* Configure with --with-system-tommath to use Debian's libtommath-dev
  instead of the bundled one.
* Updated *Depends (dropped essential packages and removed versions where
  etch already satisfies the dependencies).
* SONAME bump: libclamav5 -> libclamav6
* Build-Depend on libltdl3-dev to avoid using the bundled libltdl, but still
  get support for runtime loading (nonfree) unrar code if the user so
  decides.
* Fixed watch file to deal with new versioning schema (+dfsg).
* Run make check unless nocheck is in DEB_BUILD_OPTIONS
* Changed Section of clamav-dbg to debug.
* Override lintian error stating that libclamav6 statically links to zlib
  (lintian is right, libclamav6 does indeed duplicate parts of the zlib
  code, but there is not way around that).
* Handle new option SafeBrowsing in freshclam.conf.
* Create symlinks to AUTHORS, not AUTHORS.gz (closes: #520172).
* clamav-milter got its own config file and logging options, handled via
  debconf, added logrotation (closes: #518628)

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
  case COMP_BZIP2:
94
94
    memset(&n->bz, 0, sizeof(nsis_bzstream));
95
95
    if (nsis_BZ2_bzDecompressInit(&n->bz, 0, 0)!=BZ_OK)
96
 
      return CL_EBZIP;
 
96
      return CL_EUNPACK;
97
97
    n->freecomp=1;
98
98
    break;
99
99
  case COMP_LZMA:
203
203
 
204
204
  if ((n->ofd=open(n->ofn, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600))==-1) {
205
205
    cli_errmsg("NSIS: unable to create output file %s - aborting.", n->ofn);
206
 
    return CL_EIO;
 
206
    return CL_ECREAT;
207
207
  }
208
208
 
209
209
  if (!n->solid) {
232
232
 
233
233
    if ((ret=cli_checklimits("NSIS", ctx, size, 0, 0))!=CL_CLEAN) {
234
234
      close(n->ofd);
235
 
      if (lseek(n->ifd, size, SEEK_CUR)==-1) return CL_EIO;
 
235
      if (lseek(n->ifd, size, SEEK_CUR)==-1) return CL_ESEEK;
236
236
      return ret;
237
237
    }
238
238
    if (!(ibuf= (unsigned char *) cli_malloc(size))) {
244
244
      cli_dbgmsg("NSIS: cannot read %u bytes"__AT__"\n", size);
245
245
      free(ibuf);
246
246
      close(n->ofd);
247
 
      return CL_EIO;
 
247
      return CL_EREAD;
248
248
    }
249
249
    if (loops==size) {
250
250
      if (cli_writen(n->ofd, ibuf, size) != (ssize_t) size) {
251
251
        cli_dbgmsg("NSIS: cannot write output file"__AT__"\n");
252
252
        free(ibuf);
253
253
        close(n->ofd);
254
 
        return CL_EIO;
 
254
        return CL_EWRITE;
255
255
      }
256
256
    } else {
257
257
      if ((ret=nsis_init(n))!=CL_SUCCESS) {
275
275
            free(ibuf);
276
276
            close(n->ofd);
277
277
            nsis_shutdown(n);
278
 
            return CL_EIO;
 
278
            return CL_EWRITE;
279
279
          }
280
280
          n->nsis.next_out = obuf;
281
281
          n->nsis.avail_out = BUFSIZ;
301
301
          cli_dbgmsg("NSIS: cannot write output file"__AT__"\n");
302
302
          free(ibuf);
303
303
          close(n->ofd);
304
 
          return CL_EIO;
 
304
          return CL_EWRITE;
305
305
        }
306
306
      }
307
307
 
333
333
      if((n->freeme= (unsigned char *)mmap(NULL, n->fullsz, PROT_READ, MAP_PRIVATE, n->ifd, 0))==MAP_FAILED) {
334
334
        cli_dbgmsg("NSIS: mmap() failed"__AT__"\n");
335
335
        close(n->ofd);
336
 
        return CL_EIO;
 
336
        return CL_EMAP;
337
337
      }
338
338
      n->nsis.next_in = n->freeme+n->off+0x1c;
339
339
#else /* HAVE_MMAP */
350
350
      if (cli_readn(n->ifd, n->freeme, n->asz) != (ssize_t) n->asz) {
351
351
        cli_dbgmsg("NSIS: cannot read %u bytes"__AT__"\n", n->asz);
352
352
        close(n->ofd);
353
 
        return CL_EIO;
 
353
        return CL_EREAD;
354
354
      }
355
355
      n->nsis.next_in = n->freeme;
356
356
#endif /* HAVE_MMAP */
398
398
        if (cli_writen(n->ofd, obuf, wsz) != (ssize_t) wsz) {
399
399
          cli_dbgmsg("NSIS: cannot write output file"__AT__"\n");
400
400
          close(n->ofd);
401
 
          return CL_EIO;
 
401
          return CL_EWRITE;
402
402
        }
403
403
        size-=wsz;
404
404
        loops=0;
416
416
      if (cli_writen(n->ofd, obuf, n->nsis.next_out - obuf) != n->nsis.next_out - obuf) {
417
417
        cli_dbgmsg("NSIS: cannot write output file"__AT__"\n");
418
418
        close(n->ofd);
419
 
        return CL_EIO;
 
419
        return CL_EWRITE;
420
420
      }
421
421
    }
422
422
 
456
456
  if (fstat(n->ifd, &st)==-1 ||
457
457
      lseek(n->ifd, n->off, SEEK_SET)==-1 ||
458
458
      cli_readn(n->ifd, buf, 28) != 28)
459
 
    return CL_EIO;
 
459
    return CL_EREAD;
460
460
 
461
461
  n->hsz = (uint32_t)cli_readint32(buf+0x14);
462
462
  n->asz = (uint32_t)cli_readint32(buf+0x18);
477
477
  /* Guess if solid */
478
478
  for (i=0, pos=0;pos < n->asz-4;i++) {
479
479
    int32_t nextsz;
480
 
    if (cli_readn(n->ifd, buf+4, 4)!=4) return CL_EIO;
 
480
    if (cli_readn(n->ifd, buf+4, 4)!=4) return CL_EREAD;
481
481
    nextsz=cli_readint32(buf+4);
482
482
    if (!i) n->comp = nsis_detcomp(buf+4);
483
483
    if (nextsz&0x80000000) {
484
484
      nextsz&=~0x80000000;
485
 
      if (cli_readn(n->ifd, buf+4, 4)!=4) return CL_EIO;
 
485
      if (cli_readn(n->ifd, buf+4, 4)!=4) return CL_EREAD;
486
486
      comps[nsis_detcomp(buf+4)]++;
487
487
      nextsz-=4;
488
488
      pos+=4;
492
492
      break;
493
493
    }
494
494
 
495
 
    if (lseek(n->ifd, nextsz, SEEK_CUR)==-1) return CL_EIO;
 
495
    if (lseek(n->ifd, nextsz, SEEK_CUR)==-1) return CL_ESEEK;
496
496
  }
497
497
  
498
498
  if (trunc && i>=2) n->solid=0;
505
505
    n->comp = (comps[1]<comps[2]) ? (comps[2]<comps[3] ? COMP_ZLIB : COMP_LZMA) : (comps[1]<comps[3] ? COMP_ZLIB : COMP_BZIP2);
506
506
  }
507
507
 
508
 
  if (lseek(n->ifd, n->off+0x1c, SEEK_SET)==-1) return CL_EIO;
 
508
  if (lseek(n->ifd, n->off+0x1c, SEEK_SET)==-1) return CL_ESEEK;
509
509
 
510
510
  return nsis_unpack_next(n, ctx);
511
511
}
537
537
 
538
538
    nsist.ifd = desc;
539
539
    nsist.off = offset;
540
 
    if (!(nsist.dir = cli_gentemp(NULL)))
 
540
    if (!(nsist.dir = cli_gentemp(ctx->engine->tmpdir)))
541
541
        return CL_ETMPDIR;
542
542
    if(mkdir(nsist.dir, 0700)) {
543
543
        cli_dbgmsg("NSIS: Can't create temporary directory %s\n", nsist.dir);
545
545
        return CL_ETMPDIR;
546
546
    }
547
547
 
548
 
    if(cli_leavetemps_flag) cli_dbgmsg("NSIS: Extracting files to %s\n", nsist.dir);
 
548
    if(ctx->engine->keeptmp) cli_dbgmsg("NSIS: Extracting files to %s\n", nsist.dir);
549
549
 
550
550
    do {
551
551
        ret = cli_nsis_unpack(&nsist, ctx);
557
557
          else
558
558
            ret=cli_magic_scandesc(nsist.ofd, ctx);
559
559
          close(nsist.ofd);
560
 
          if(!cli_leavetemps_flag)
561
 
            if(cli_unlink(nsist.ofn)) ret = CL_EIO;
 
560
          if(!ctx->engine->keeptmp)
 
561
            if(cli_unlink(nsist.ofn)) ret = CL_EUNLINK;
562
562
        } else if(ret == CL_EMAXSIZE) {
563
563
            ret = nsist.solid ? CL_BREAK : CL_SUCCESS;
564
564
        }
569
569
 
570
570
    cli_nsis_free(&nsist);
571
571
 
572
 
    if(!cli_leavetemps_flag)
 
572
    if(!ctx->engine->keeptmp)
573
573
        cli_rmdirs(nsist.dir);
574
574
 
575
575
    free(nsist.dir);