~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamunrar_iface/unrar_iface.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "clamav-config.h"
22
22
#endif
23
23
 
24
 
/* TODO: Add support for dlopen()&Co. */
25
 
 
26
24
#include <stdio.h>
27
25
#include <string.h>
28
26
#include <sys/types.h>
50
48
}
51
49
#endif
52
50
 
53
 
#ifndef O_BINARY
54
 
#define O_BINARY    0
55
 
#endif
56
 
 
57
51
/* FIXME: allow this to be controlled from unrar_open or so */
58
52
#ifdef RAR_DEBUG_MODE
59
53
#define unrar_dbgmsg printf
278
272
        return UNRAR_PASSWD;
279
273
    }
280
274
 
281
 
    snprintf(filename,1024,"%s/comments", dirname);
 
275
    snprintf(filename,1024,"%s"PATHSEP"comments", dirname);
282
276
    if(mkdir(filename,0700)) {
283
277
        unrar_dbgmsg("UNRAR: Unable to create comment temporary directory\n");
284
278
        free(main_hdr);
296
290
        return UNRAR_ERR;
297
291
    }
298
292
 
299
 
    unpack_data = (unpack_data_t *) malloc(sizeof(unpack_data_t));
 
293
    unpack_data = (unpack_data_t *) calloc(1, sizeof(unpack_data_t));
300
294
    if(!unpack_data) {
301
295
        free(main_hdr);
302
296
        free(state->comment_dir);
324
318
            unrar_dbgmsg("UNRAR: UnPack Size: 0x%.4x\n", comment_header->unpack_size);
325
319
            unrar_dbgmsg("UNRAR: UnPack Version: 0x%.2x\n", comment_header->unpack_ver);
326
320
            unrar_dbgmsg("UNRAR: Pack Method: 0x%.2x\n", comment_header->method);
327
 
            snprintf(filename, 1024, "%s/main.cmt", state->comment_dir);
 
321
            snprintf(filename, 1024, "%s"PATHSEP"main.cmt", state->comment_dir);
328
322
            ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600);
329
323
            if(ofd < 0) {
330
324
                unrar_dbgmsg("UNRAR: ERROR: Failed to open output file\n");
422
416
            if((comment_header->unpack_ver < 15) || (comment_header->unpack_ver > 29) || (comment_header->method > 0x30)) {
423
417
                unrar_dbgmsg("UNRAR: Can't process file comment - skipping\n");
424
418
            } else {
425
 
                snprintf(filename, 1024, "%s/%lu.cmt", state->comment_dir, state->file_count);
 
419
                snprintf(filename, 1024, "%s"PATHSEP"%lu.cmt", state->comment_dir, state->file_count);
426
420
                ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600);
427
421
                if(ofd < 0) {
428
422
                    free(comment_header);
464
458
        unrar_dbgmsg("UNRAR: Skipping file inside multi-volume solid archive\n");
465
459
 
466
460
    } else {
467
 
        snprintf(state->filename, 1024, "%s/%lu.ura", dirname, state->file_count);
 
461
        snprintf(state->filename, 1024, "%s"PATHSEP"%lu.ura", dirname, state->file_count);
468
462
        ofd = open(state->filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
469
463
        if(ofd < 0) {
470
464
            free(state->file_header->filename);
535
529
    free(state->unpack_data);
536
530
    free(state->comment_dir);
537
531
}
538
 
 
539
 
#ifdef  C_WINDOWS
540
 
/*
541
 
 * A copy is needed here to avoid a cyclic dependancy libclamunrar_iface<->libclamav
542
 
 * e.g. see the comment in bug 775 about dropping the old internal snprintf
543
 
 * which didn't have this problem and bug 785
544
 
 */
545
 
#include <stdarg.h>
546
 
static int
547
 
snprintf(char *str, size_t size, const char *format, ...)
548
 
{
549
 
        int ret;
550
 
 
551
 
        va_list args;
552
 
        va_start(args, format);
553
 
        ret = _vsnprintf_s(str, size, _TRUNCATE, format, args);
554
 
        va_end(args);
555
 
        return ret;
556
 
}
557
 
#endif