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

« back to all changes in this revision

Viewing changes to libclamav/zziplib/zzip-zip.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2006-01-10 02:55:18 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060110025518-92bhgfe911byl3bc
Tags: upstream-0.88
ImportĀ upstreamĀ versionĀ 0.88

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include "clamav-config.h"
16
16
#endif
17
17
 
 
18
#include "target.h"
 
19
 
18
20
#include <zzip.h>                                  /* archive handling */
19
21
#include <zzip-file.h>
20
22
#include <zzipformat.h>
259
261
                { return(ZZIP_DIR_SEEK); }
260
262
            if (io->read(fd, buf, (zzip_size_t)maplen) < (zzip_ssize_t)maplen)
261
263
                { return(ZZIP_DIR_READ); }
262
 
            mapped = buf; /* success */
 
264
            mapped = (unsigned char *) buf; /* success */
263
265
            /*
264
266
            HINT5("offs=$%lx len=%li filesize=%li pagesize=%i", 
265
267
                (long)offset, (long)maplen, (long)filesize, ZZIP_BUFSIZ);
387
389
                return ZZIP_DIR_SEEK;
388
390
            }
389
391
            if (io->read(fd, &dirent, sizeof(dirent)) < __sizeof(dirent)) {
390
 
                free(hdr0);
391
 
                return ZZIP_DIR_READ;
 
392
                if(entries != u_entries) {
 
393
                    entries = 0;
 
394
                    break;
 
395
                } else {
 
396
                    free(hdr0);
 
397
                    return ZZIP_DIR_READ;
 
398
                }
392
399
            }
393
400
            d = &dirent;
394
401
        }
424
431
                return ZZIP_DIR_READ;
425
432
        }
426
433
        hdr->d_compr = (uint8_t)ZZIP_GET16(d->z_compr);
 
434
 
 
435
        /* If d_compr is incorrect scanning will result in CL_EZIP (Zip
 
436
         * module failure)
 
437
         */
 
438
        if(!hdr->d_compr && hdr->d_csize != hdr->d_usize) {
 
439
            cli_dbgmsg("Zziplib: File claims to be stored but csize != usize\n");
 
440
            cli_dbgmsg("Zziplib: Switching to the inflate method\n");
 
441
            hdr->d_compr = 8;
 
442
        } else if(hdr->d_compr && hdr->d_csize == hdr->d_usize) {
 
443
            cli_dbgmsg("Zziplib: File claims to be deflated but csize == usize\n");
 
444
            cli_dbgmsg("Zziplib: Switching to the stored method\n");
 
445
            hdr->d_compr = 0;
 
446
        }
 
447
 
427
448
        hdr->d_flags = u_flags;
428
449
 
429
450
        /* bull: hdr->d_compr is uint8_t
621
642
{
622
643
    zzip_error_t rv;
623
644
    zzip_off_t filesize;
 
645
#if (defined(TARGET_CPU_SPARC64) || defined(TARGET_CPU_SPARC)) && defined(HAVE_ATTRIB_ALIGNED)
 
646
    struct zzip_disk_trailer trailer __attribute__((aligned));
 
647
#else
624
648
    struct zzip_disk_trailer trailer;
 
649
#endif
625
650
    /* if (! dir || dir->fd < 0) 
626
651
     *     { rv = EINVAL; goto error; } 
627
652
     */