~ubuntu-branches/ubuntu/trusty/clamav/trusty-proposed

« back to all changes in this revision

Viewing changes to libclamav/mspack/cab.h

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2005-09-19 09:05:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050919090559-hikpqduq8yx5qxo2
Tags: 0.87-1
* New upstream version
  - Fixes CAN-2005-2920 and CAN-2005-2919 (closes: #328660)
* New logcheck line for clamav-daemon (closes: #323132)
* relibtoolize and apply kfreebsd patch (closes: #327707)
* Make sure init.d script starts freshclam up again after upgrade when run
  from if-up.d (closes: #328912)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of libmspack.
 
2
 * (C) 2003-2004 Stuart Caie.
 
3
 *
 
4
 * libmspack is free software; you can redistribute it and/or modify it under
 
5
 * the terms of the GNU Lesser General Public License (LGPL) version 2.1
 
6
 *
 
7
 * For further details, see the file COPYING.LIB distributed with libmspack
 
8
 */
 
9
 
 
10
#ifndef MSPACK_CAB_H
 
11
#define MSPACK_CAB_H 1
 
12
 
 
13
#include <mszip.h>
 
14
#include <qtm.h>
 
15
#include <lzx.h>
 
16
 
 
17
/* generic CAB definitions */
 
18
 
 
19
/* structure offsets */
 
20
#define cfhead_Signature         (0x00)
 
21
#define cfhead_CabinetSize       (0x08)
 
22
#define cfhead_FileOffset        (0x10)
 
23
#define cfhead_MinorVersion      (0x18)
 
24
#define cfhead_MajorVersion      (0x19)
 
25
#define cfhead_NumFolders        (0x1A)
 
26
#define cfhead_NumFiles          (0x1C)
 
27
#define cfhead_Flags             (0x1E)
 
28
#define cfhead_SetID             (0x20)
 
29
#define cfhead_CabinetIndex      (0x22)
 
30
#define cfhead_SIZEOF            (0x24)
 
31
#define cfheadext_HeaderReserved (0x00)
 
32
#define cfheadext_FolderReserved (0x02)
 
33
#define cfheadext_DataReserved   (0x03)
 
34
#define cfheadext_SIZEOF         (0x04)
 
35
#define cffold_DataOffset        (0x00)
 
36
#define cffold_NumBlocks         (0x04)
 
37
#define cffold_CompType          (0x06)
 
38
#define cffold_SIZEOF            (0x08)
 
39
#define cffile_UncompressedSize  (0x00)
 
40
#define cffile_FolderOffset      (0x04)
 
41
#define cffile_FolderIndex       (0x08)
 
42
#define cffile_Date              (0x0A)
 
43
#define cffile_Time              (0x0C)
 
44
#define cffile_Attribs           (0x0E)
 
45
#define cffile_SIZEOF            (0x10)
 
46
#define cfdata_CheckSum          (0x00)
 
47
#define cfdata_CompressedSize    (0x04)
 
48
#define cfdata_UncompressedSize  (0x06)
 
49
#define cfdata_SIZEOF            (0x08)
 
50
 
 
51
/* flags */
 
52
#define cffoldCOMPTYPE_MASK            (0x000f)
 
53
#define cffoldCOMPTYPE_NONE            (0x0000)
 
54
#define cffoldCOMPTYPE_MSZIP           (0x0001)
 
55
#define cffoldCOMPTYPE_QUANTUM         (0x0002)
 
56
#define cffoldCOMPTYPE_LZX             (0x0003)
 
57
#define cfheadPREV_CABINET             (0x0001)
 
58
#define cfheadNEXT_CABINET             (0x0002)
 
59
#define cfheadRESERVE_PRESENT          (0x0004)
 
60
#define cffileCONTINUED_FROM_PREV      (0xFFFD)
 
61
#define cffileCONTINUED_TO_NEXT        (0xFFFE)
 
62
#define cffileCONTINUED_PREV_AND_NEXT  (0xFFFF)
 
63
 
 
64
/* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed
 
65
 * blocks have zero growth. MSZIP guarantees that it won't grow above
 
66
 * uncompressed size by more than 12 bytes. LZX guarantees it won't grow
 
67
 * more than 6144 bytes. Quantum has no documentation, but the largest
 
68
 * block seen in the wild is 337 bytes above uncompressed size.
 
69
 */
 
70
#define CAB_BLOCKMAX (32768)
 
71
#define CAB_INPUTMAX (CAB_BLOCKMAX+6144)
 
72
 
 
73
/* CAB compression definitions */
 
74
 
 
75
struct mscab_compressor_p {
 
76
  struct mscab_compressor base;
 
77
  struct mspack_system *system;
 
78
  /* todo */
 
79
};
 
80
 
 
81
/* CAB decompression definitions */
 
82
 
 
83
struct mscabd_decompress_state {
 
84
  struct mscabd_folder_p *folder;    /* current folder we're extracting from */
 
85
  struct mscabd_folder_data *data;   /* current folder split we're in        */
 
86
  unsigned int offset;               /* uncompressed offset within folder    */
 
87
  unsigned int block;                /* which block are we decompressing?    */
 
88
  struct mspack_system sys;          /* special I/O code for decompressor    */
 
89
  int comp_type;                     /* type of compression used by folder   */
 
90
  int (*decompress)(void *, off_t);  /* decompressor code                    */
 
91
  void *state;                       /* decompressor state                   */
 
92
  struct mscabd_cabinet_p *incab;    /* cabinet where input data comes from  */
 
93
  struct mspack_file *infh;          /* input file handle                    */
 
94
  struct mspack_file *outfh;         /* output file handle                   */
 
95
  unsigned char *i_ptr, *i_end;      /* input data consumed, end             */
 
96
  unsigned char input[CAB_INPUTMAX]; /* one input block of data              */
 
97
};
 
98
 
 
99
struct mscab_decompressor_p {
 
100
  struct mscab_decompressor base;
 
101
  struct mscabd_decompress_state *d;
 
102
  struct mspack_system *system;
 
103
  int param[3]; /* !!! MATCH THIS TO NUM OF PARAMS IN MSPACK.H !!! */
 
104
  int error;
 
105
};
 
106
 
 
107
struct mscabd_cabinet_p {
 
108
  struct mscabd_cabinet base;
 
109
  off_t blocks_off;                  /* offset to data blocks                */
 
110
  int block_resv;                    /* reserved space in data blocks        */
 
111
};
 
112
 
 
113
/* there is one of these for every cabinet a folder spans */
 
114
struct mscabd_folder_data {
 
115
  struct mscabd_folder_data *next;
 
116
  struct mscabd_cabinet_p *cab;      /* cabinet file of this folder span     */
 
117
  off_t offset;                      /* cabinet offset of first datablock    */
 
118
};
 
119
 
 
120
struct mscabd_folder_p {
 
121
  struct mscabd_folder base;
 
122
  struct mscabd_folder_data data;    /* where are the data blocks?           */
 
123
  struct mscabd_file *merge_prev;    /* do we need to merge backwards?       */
 
124
  struct mscabd_file *merge_next;    /* do we need to merge forwards?        */
 
125
};
 
126
 
 
127
#endif