Browse code

(hopefully) all the stuff lost

git-svn-id: file:///var/lib/svn/clamav-devel/branches/not_for_0.92_tempbranch@3388 77e5149b-7576-45b1-b177-96237e5ba77b

aCaB authored on 2007/12/11 07:17:06
Showing 36 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+Modified files from libbzip2 are present under libclamav/nsis.
1
+The original LICENSE file for bzip2 and libbzip2 is reproduced below.
2
+
3
+--------------------------------------------------------------------------
4
+
5
+This program, "bzip2", the associated library "libbzip2", and all
6
+documentation, are copyright (C) 1996-2006 Julian R Seward.  All
7
+rights reserved.
8
+
9
+Redistribution and use in source and binary forms, with or without
10
+modification, are permitted provided that the following conditions
11
+are met:
12
+
13
+1. Redistributions of source code must retain the above copyright
14
+   notice, this list of conditions and the following disclaimer.
15
+
16
+2. The origin of this software must not be misrepresented; you must 
17
+   not claim that you wrote the original software.  If you use this 
18
+   software in a product, an acknowledgment in the product 
19
+   documentation would be appreciated but is not required.
20
+
21
+3. Altered source versions must be plainly marked as such, and must
22
+   not be misrepresented as being the original software.
23
+
24
+4. The name of the author may not be used to endorse or promote 
25
+   products derived from this software without specific prior written 
26
+   permission.
27
+
28
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
29
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
32
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
34
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
+
40
+Julian Seward, Cambridge, UK.
41
+jseward@bzip.org
42
+bzip2/libbzip2 version 1.0.4 of 20 December 2006
43
+
44
+--------------------------------------------------------------------------
0 45
new file mode 100644
... ...
@@ -0,0 +1,72 @@
0
+Original unmodified files from the LZMA SDK are included under libclamav/lzma.
1
+The original lzma.txt license file, a small portion of which is reproduced below,
2
+is available under libclamav/lzma/lzma.txt. 
3
+
4
+LICENSE
5
+-------
6
+
7
+LZMA SDK is available under any of the following licenses:
8
+
9
+1) GNU Lesser General Public License (GNU LGPL)
10
+2) Common Public License (CPL)
11
+3) Simplified license for unmodified code (read SPECIAL EXCEPTION) 
12
+4) Proprietary license 
13
+
14
+It means that you can select one of these four options and follow rules of that license.
15
+
16
+
17
+1,2) GNU LGPL and CPL licenses are pretty similar and both these
18
+licenses are classified as 
19
+ - "Free software licenses" at http://www.gnu.org/ 
20
+ - "OSI-approved" at http://www.opensource.org/
21
+
22
+
23
+3) SPECIAL EXCEPTION
24
+
25
+Igor Pavlov, as the author of this code, expressly permits you 
26
+to statically or dynamically link your code (or bind by name) 
27
+to the files from LZMA SDK without subjecting your linked 
28
+code to the terms of the CPL or GNU LGPL. 
29
+Any modifications or additions to files from LZMA SDK, however, 
30
+are subject to the GNU LGPL or CPL terms.
31
+
32
+SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code, 
33
+while you keep LZMA SDK code unmodified.
34
+
35
+
36
+SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits 
37
+you to use this code under the same terms and conditions contained in the License 
38
+Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov.
39
+
40
+SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version 
41
+of LZMA SDK as update for previous versions.
42
+
43
+
44
+SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits 
45
+you to use code of the following files: 
46
+BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp, 
47
+LzmaAlone.cs, LzmaAlone.java
48
+as public domain code. 
49
+
50
+
51
+4) Proprietary license
52
+
53
+LZMA SDK also can be available under a proprietary license which 
54
+can include:
55
+
56
+1) Right to modify code without subjecting modified code to the 
57
+terms of the CPL or GNU LGPL
58
+2) Technical support for code
59
+
60
+To request such proprietary license or any additional consultations,
61
+send email message from that page:
62
+http://www.7-zip.org/support.html
63
+
64
+
65
+You should have received a copy of the GNU Lesser General Public
66
+License along with this library; if not, write to the Free Software
67
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
68
+
69
+You should have received a copy of the Common Public License
70
+along with this library.
71
+
0 72
deleted file mode 100644
... ...
@@ -1,308 +0,0 @@
1
-********************************************************************************
2
-   This document contains licence details for files in libclamav/nsis. It can
3
-   be accessed on-line at http://nsis.sourceforge.net/License
4
-********************************************************************************
5
-
6
-Copyright (C) 1995-2007 Contributors 
7
-
8
-More detailed copyright information can be found in the individual source code 
9
-files. 
10
-
11
-Applicable licenses 
12
-
13
-* All NSIS source code, plug-ins, documentation, examples, header files and 
14
-  graphics, with the exception of the compression modules and where otherwise 
15
-  noted, are licensed under the zlib/libpng license. 
16
-
17
-* The zlib compression module for NSIS is licensed under the zlib/libpng
18
-  license. 
19
-
20
-* The bzip2 compression module for NSIS is licensed under the bzip2 license. 
21
-
22
-* The lzma compression module for NSIS is licensed under the Common Public
23
-  License version 1.0. 
24
-
25
-zlib/libpng license 
26
-
27
-This software is provided 'as-is', without any express or implied warranty. In 
28
-no event will the authors be held liable for any damages arising from the use
29
-of this software. 
30
-
31
-Permission is granted to anyone to use this software for any purpose, including 
32
-commercial applications, and to alter it and redistribute it freely, subject to 
33
-the following restrictions: 
34
-
35
-  1. The origin of this software must not be misrepresented; you must not
36
-     claim that you wrote the original software. If you use this software in
37
-     a product, an acknowledgment in the product documentation would be
38
-     appreciated but is not required. 
39
-
40
-  2. Altered source versions must be plainly marked as such, and must not be
41
-     misrepresented as being the original software. 
42
-
43
-  3. This notice may not be removed or altered from any source distribution. 
44
-
45
-bzip2 license 
46
-
47
-Redistribution and use in source and binary forms, with or without
48
-modification, are permitted provided that the following conditions are met: 
49
-
50
-  1. Redistributions of source code must retain the above copyright notice,
51
-     this list of conditions and the following disclaimer.
52
-
53
-  2. The origin of this software must not be misrepresented; you must not
54
-     claim that you wrote the original software. If you use this software in
55
-     a product, an acknowledgment in the product documentation would be
56
-     appreciated but is not required. 
57
-
58
-  3. Altered source versions must be plainly marked as such, and must not be
59
-     misrepresented as being the original software.
60
-
61
-  4. The name of the author may not be used to endorse or promote products
62
-     derived from this software without specific prior written permission. 
63
-
64
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED 
65
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
66
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
67
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
68
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
69
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
70
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
71
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
72
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
73
-OF SUCH DAMAGE. 
74
-
75
-Julian Seward, Cambridge, UK. 
76
-
77
-jseward@acm.org 
78
-
79
-Common Public License version 1.0 
80
-
81
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC 
82
-LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 
83
-CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 
84
-
85
-1. DEFINITIONS 
86
-
87
-"Contribution" means: 
88
-
89
-a) in the case of the initial Contributor, the initial code and documentation 
90
-   distributed under this Agreement, and b) in the case of each subsequent 
91
-   Contributor: 
92
-
93
-i) changes to the Program, and 
94
-
95
-ii) additions to the Program; 
96
-
97
-where such changes and/or additions to the Program originate from and are 
98
-distributed by that particular Contributor. A Contribution 'originates' from a 
99
-Contributor if it was added to the Program by such Contributor itself or anyone 
100
-acting on such Contributor's behalf. Contributions do not include additions to 
101
-the Program which: (i) are separate modules of software distributed in 
102
-conjunction with the Program under their own license agreement, and (ii) are
103
-not derivative works of the Program. 
104
-
105
-"Contributor" means any person or entity that distributes the Program. 
106
-
107
-"Licensed Patents " mean patent claims licensable by a Contributor which are 
108
-necessarily infringed by the use or sale of its Contribution alone or when 
109
-combined with the Program. 
110
-
111
-"Program" means the Contributions distributed in accordance with this Agreement.
112
-
113
-"Recipient" means anyone who receives the Program under this Agreement, 
114
-including all Contributors. 
115
-
116
-2. GRANT OF RIGHTS 
117
-
118
-a) Subject to the terms of this Agreement, each Contributor hereby grants 
119
-Recipient a non-exclusive, worldwide, royalty-free copyright license to 
120
-reproduce, prepare derivative works of, publicly display, publicly perform, 
121
-distribute and sublicense the Contribution of such Contributor, if any, and
122
-such derivative works, in source code and object code form. 
123
-
124
-b) Subject to the terms of this Agreement, each Contributor hereby grants 
125
-Recipient a non-exclusive, worldwide, royalty-free patent license under
126
-Licensed Patents to make, use, sell, offer to sell, import and otherwise
127
-transfer the Contribution of such Contributor, if any, in source code and
128
-object code form. This patent license shall apply to the combination of the
129
-Contribution and the Program if, at the time the Contribution is added by the
130
-Contributor, such addition of the Contribution causes such combination to be
131
-covered by the Licensed Patents. The patent license shall not apply to any
132
-other combinations which include the Contribution. No hardware per se is
133
-licensed hereunder.
134
-
135
-c) Recipient understands that although each Contributor grants the licenses to 
136
-its Contributions set forth herein, no assurances are provided by any 
137
-Contributor that the Program does not infringe the patent or other intellectual 
138
-property rights of any other entity. Each Contributor disclaims any liability
139
-to Recipient for claims brought by any other entity based on infringement of 
140
-intellectual property rights or otherwise. As a condition to exercising the 
141
-rights and licenses granted hereunder, each Recipient hereby assumes sole 
142
-responsibility to secure any other intellectual property rights needed, if any. 
143
-For example, if a third party patent license is required to allow Recipient to 
144
-distribute the Program, it is Recipient's responsibility to acquire that
145
-license before distributing the Program. 
146
-
147
-d) Each Contributor represents that to its knowledge it has sufficient
148
-copyright rights in its Contribution, if any, to grant the copyright license
149
-set forth in this Agreement. 
150
-
151
-3. REQUIREMENTS 
152
-
153
-A Contributor may choose to distribute the Program in object code form under
154
-its own license agreement, provided that: 
155
-
156
-a) it complies with the terms and conditions of this Agreement; and 
157
-
158
-b) its license agreement: 
159
-
160
-i) effectively disclaims on behalf of all Contributors all warranties and 
161
-conditions, express and implied, including warranties or conditions of title
162
-and non-infringement, and implied warranties or conditions of merchantability
163
-and fitness for a particular purpose; 
164
-
165
-ii) effectively excludes on behalf of all Contributors all liability for
166
-damages, including direct, indirect, special, incidental and consequential
167
-damages, such as lost profits; 
168
-
169
-iii) states that any provisions which differ from this Agreement are offered by 
170
-that Contributor alone and not by any other party; and 
171
-
172
-iv) states that source code for the Program is available from such Contributor, 
173
-and informs licensees how to obtain it in a reasonable manner on or through a 
174
-medium customarily used for software exchange. 
175
-
176
-When the Program is made available in source code form: 
177
-
178
-a) it must be made available under this Agreement; and 
179
-
180
-b) a copy of this Agreement must be included with each copy of the Program. 
181
-
182
-Contributors may not remove or alter any copyright notices contained within the 
183
-Program. 
184
-
185
-Each Contributor must identify itself as the originator of its Contribution, if 
186
-any, in a manner that reasonably allows subsequent Recipients to identify the 
187
-originator of the Contribution. 
188
-
189
-4. COMMERCIAL DISTRIBUTION 
190
-
191
-Commercial distributors of software may accept certain responsibilities with 
192
-respect to end users, business partners and the like. While this license is 
193
-intended to facilitate the commercial use of the Program, the Contributor who 
194
-includes the Program in a commercial product offering should do so in a manner 
195
-which does not create potential liability for other Contributors. Therefore, if 
196
-a Contributor includes the Program in a commercial product offering, such 
197
-Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 
198
-every other Contributor ("Indemnified Contributor") against any losses, damages 
199
-and costs (collectively "Losses") arising from claims, lawsuits and other legal 
200
-actions brought by a third party against the Indemnified Contributor to the 
201
-extent caused by the acts or omissions of such Commercial Contributor in 
202
-connection with its distribution of the Program in a commercial product
203
-offering. The obligations in this section do not apply to any claims or Losses
204
-relating to any actual or alleged intellectual property infringement. In order
205
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
206
-Contributor in writing of such claim, and b) allow the Commercial Contributor
207
-to control, and cooperate with the Commercial Contributor in, the defense and
208
-any related settlement negotiations. The Indemnified Contributor may
209
-participate in any such claim at its own expense. 
210
-
211
-For example, a Contributor might include the Program in a commercial product 
212
-offering, Product X. That Contributor is then a Commercial Contributor. If that 
213
-Commercial Contributor then makes performance claims, or offers warranties 
214
-related to Product X, those performance claims and warranties are such 
215
-Commercial Contributor's responsibility alone. Under this section, the 
216
-Commercial Contributor would have to defend claims against the other 
217
-Contributors related to those performance claims and warranties, and if a court 
218
-requires any other Contributor to pay any damages as a result, the Commercial 
219
-Contributor must pay those damages. 
220
-
221
-5. NO WARRANTY 
222
-
223
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
224
-AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS
225
-OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
226
-TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
227
-Each Recipient is solely responsible for determining the appropriateness of
228
-using and distributing the Program and assumes all risks associated with its
229
-exercise of rights under this Agreement, including but not limited to the risks
230
-and costs of program errors, compliance with applicable laws, damage to or loss
231
-of data, programs or equipment, and unavailability or interruption of
232
-operations. 
233
-
234
-6. DISCLAIMER OF LIABILITY 
235
-
236
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 
237
-CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
238
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 
239
-PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
240
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
241
-WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
242
-GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
243
-
244
-7. GENERAL 
245
-
246
-If any provision of this Agreement is invalid or unenforceable under applicable 
247
-law, it shall not affect the validity or enforceability of the remainder of the 
248
-terms of this Agreement, and without further action by the parties hereto, such 
249
-provision shall be reformed to the minimum extent necessary to make such 
250
-provision valid and enforceable. 
251
-
252
-If Recipient institutes patent litigation against a Contributor with respect to 
253
-a patent applicable to software (including a cross-claim or counterclaim in a 
254
-lawsuit), then any patent licenses granted by that Contributor to such
255
-Recipient under this Agreement shall terminate as of the date such litigation
256
-is filed. In addition, if Recipient institutes patent litigation against any
257
-entity (including a cross-claim or counterclaim in a lawsuit) alleging that the
258
-Program itself (excluding combinations of the Program with other software or
259
-hardware) infringes such Recipient's patent(s), then such Recipient's rights
260
-granted under Section 2(b) shall terminate as of the date such litigation is
261
-filed. 
262
-
263
-All Recipient's rights under this Agreement shall terminate if it fails to 
264
-comply with any of the material terms or conditions of this Agreement and does 
265
-not cure such failure in a reasonable period of time after becoming aware of 
266
-such noncompliance. If all Recipient's rights under this Agreement terminate, 
267
-Recipient agrees to cease use and distribution of the Program as soon as 
268
-reasonably practicable. However, Recipient's obligations under this Agreement 
269
-and any licenses granted by Recipient relating to the Program shall continue
270
-and survive. 
271
-
272
-Everyone is permitted to copy and distribute copies of this Agreement, but in 
273
-order to avoid inconsistency the Agreement is copyrighted and may only be 
274
-modified in the following manner. The Agreement Steward reserves the right to 
275
-publish new versions (including revisions) of this Agreement from time to time. 
276
-No one other than the Agreement Steward has the right to modify this Agreement. 
277
-IBM is the initial Agreement Steward. IBM may assign the responsibility to
278
-serve as the Agreement Steward to a suitable separate entity. Each new version
279
-of the Agreement will be given a distinguishing version number. The Program
280
-(including Contributions) may always be distributed subject to the version of
281
-the Agreement under which it was received. In addition, after a new version of
282
-the Agreement is published, Contributor may elect to distribute the Program
283
-(including its Contributions) under the new version. Except as expressly
284
-stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
285
-licenses to the intellectual property of any Contributor under this Agreement,
286
-whether expressly, by implication, estoppel or otherwise. All rights in the
287
-Program not expressly granted under this Agreement are reserved. 
288
-
289
-This Agreement is governed by the laws of the State of New York and the 
290
-intellectual property laws of the United States of America. No party to this 
291
-Agreement will bring a legal action under this Agreement more than one year 
292
-after the cause of action arose. Each party waives its rights to a jury trial
293
-in any resulting litigation. 
294
-
295
-Special exception for LZMA compression module 
296
-
297
-Igor Pavlov and Amir Szekely, the authors of the LZMA compression module for 
298
-NSIS, expressly permit you to statically or dynamically link your code (or bind 
299
-by name) to the files from the LZMA compression module for NSIS without 
300
-subjecting your linked code to the terms of the Common Public license version
301
-1.0.  Any modifications or additions to files from the LZMA compression module
302
-for NSIS, however, are subject to the terms of the Common Public License
303
-version 1.0. 
... ...
@@ -1,3 +1,12 @@
1
+ Wed Nov 14 21:56:33 EET 2007 (edwin)
2
+ ------------------------------------
3
+   * libclamav/phishcheck.[ch]: 
4
+     remove "all domain scan" feature from phishcheck
5
+     (--no-phishing-restrictedscan). Nobody is using it.
6
+     Don't care why an url is clean, just state it is clean.
7
+     Various cleanups resulting from this.
8
+     Prepare to introduce selective turn on of sub-features.
9
+ 
1 10
 Tue Oct  9 16:53:48 CEST 2007 (tk)
2 11
 ----------------------------------
3 12
   * 0.92rc2 (released with JS and PST code removed)
... ...
@@ -434,19 +434,6 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigne
434 434
 
435 435
     if(cfgopt(copt,"PhishingScanURLs")->enabled) {
436 436
 
437
-	if(cfgopt(copt,"PhishingRestrictedScan")->enabled) {
438
-	    /* we don't scan urls from all domains, just those listed in
439
-	     * .pdb file. This is the safe default
440
-	     */
441
-	    options |= CL_SCAN_PHISHING_DOMAINLIST;
442
-	} else {
443
-	    /* This is a false positive prone option, since newsletters, etc.
444
-	     * often contain links that will be classified as phishing attempts,
445
-	     * even though the site they link to isn't a phish site.
446
-	     */
447
-	    logg("Phishing: Checking all URLs, regardless of domain (FP prone).\n");
448
-	}
449
-
450 437
 	if(cfgopt(copt,"PhishingAlwaysBlockCloak")->enabled) {
451 438
 	    options |= CL_SCAN_PHISHING_BLOCKCLOAK; 
452 439
 	    logg("Phishing: Always checking for cloaked urls\n");
... ...
@@ -174,10 +174,6 @@ int scanmanager(const struct optstruct *opt)
174 174
 
175 175
     if(!opt_check(opt,"no-phishing-scan-urls"))
176 176
 	dboptions |= CL_DB_PHISHING_URLS;
177
-    if(!opt_check(opt,"no-phishing-restrictedscan")) {
178
-	/* not scanning all domains, check only URLs with domains from .pdb */
179
-	options |= CL_SCAN_PHISHING_DOMAINLIST;
180
-    }
181 177
     if(opt_check(opt,"phishing-ssl")) {
182 178
 	options |= CL_SCAN_PHISHING_BLOCKSSL;
183 179
     }
... ...
@@ -26359,7 +26359,7 @@ echo "$as_me: WARNING: Unable to determine FPU endianess, some features may not
26359 26359
 esac
26360 26360
 
26361 26361
 
26362
-ac_config_files="$ac_config_files libclamav/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile Makefile clamav-config libclamav.pc docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1"
26362
+ac_config_files="$ac_config_files libclamav/lzma/Makefile libclamav/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile Makefile clamav-config libclamav.pc docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1"
26363 26363
 
26364 26364
 cat >confcache <<\_ACEOF
26365 26365
 # This file is a shell script that caches the results of configure
... ...
@@ -26967,6 +26967,7 @@ do
26967 26967
   case $ac_config_target in
26968 26968
     "clamav-config.h") CONFIG_HEADERS="$CONFIG_HEADERS clamav-config.h" ;;
26969 26969
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
26970
+    "libclamav/lzma/Makefile") CONFIG_FILES="$CONFIG_FILES libclamav/lzma/Makefile" ;;
26970 26971
     "libclamav/Makefile") CONFIG_FILES="$CONFIG_FILES libclamav/Makefile" ;;
26971 26972
     "clamscan/Makefile") CONFIG_FILES="$CONFIG_FILES clamscan/Makefile" ;;
26972 26973
     "database/Makefile") CONFIG_FILES="$CONFIG_FILES database/Makefile" ;;
... ...
@@ -1204,6 +1204,7 @@ AC_MSG_RESULT($have_signed_rightshift_extended);
1204 1204
 AC_C_FPU_BIGENDIAN
1205 1205
 
1206 1206
 AC_OUTPUT([
1207
+libclamav/lzma/Makefile
1207 1208
 libclamav/Makefile
1208 1209
 clamscan/Makefile
1209 1210
 database/Makefile
... ...
@@ -255,11 +255,6 @@ Scan URLs found in mails for phishing attempts using heuristics. This will class
255 255
 .br
256 256
 Default: yes
257 257
 .TP
258
-\fBPhishingRestrictedScan BOOL\fR
259
-Use phishing detection only for domains listed in the .pdb database. It is not recommended to have this option turned off, because scanning of all domains may lead to many false positives!
260
-.br
261
-Default: yes
262
-.TP
263 258
 \fBPhishingAlwaysBlockSSLMismatch BOOL\fR
264 259
 Always block SSL mismatches in URLs, even if the URL isn't in the database. This can lead to false positives.
265 260
 .br
... ...
@@ -237,12 +237,6 @@ LocalSocket /tmp/clamd.socket
237 237
 # Default: yes
238 238
 #PhishingScanURLs yes
239 239
 
240
-# Use phishing detection only for domains listed in the .pdb database. It is
241
-# not recommended to have this option turned off, because scanning of all
242
-# domains may lead to many false positives!
243
-# Default: yes
244
-#PhishingRestrictedScan yes
245
-
246 240
 # Always block SSL mismatches in URLs, even if the URL isn't in the database.
247 241
 # This can lead to false positives.
248 242
 #
... ...
@@ -16,16 +16,16 @@
16 16
 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
 #  MA 02110-1301, USA.
18 18
 
19
+SUBDIRS = lzma .
19 20
 
20
-INCLUDES = -I$(top_srcdir) -I@srcdir@/unrar -I@srcdir@/nsis
21
+INCLUDES = -I$(top_srcdir) -I@srcdir@/unrar -I@srcdir@/nsis -I@srcdir@/lzma
21 22
 
22
-libclamav_la_LIBADD = @LIBCLAMAV_LIBS@ @THREAD_LIBS@
23
+libclamav_la_LIBADD = @LIBCLAMAV_LIBS@ @THREAD_LIBS@ lzma/liblzma.la
23 24
 
24 25
 libclamav_la_LDFLAGS = @TH_SAFE@ -version-info @LIBCLAMAV_VERSION@ -no-undefined
25 26
 
26 27
 include_HEADERS = clamav.h
27 28
 
28
-
29 29
 libclamav_la_SOURCES = \
30 30
 	clamav.h \
31 31
         matcher-ac.c \
... ...
@@ -139,15 +139,9 @@ libclamav_la_SOURCES = \
139 139
 	unrar/unrarppm.h \
140 140
 	unarj.c \
141 141
 	unarj.h \
142
-	nsis/LZMADecode.c \
143
-	nsis/LZMADecode.h \
144 142
 	nsis/bzlib.c \
145 143
 	nsis/bzlib_private.h \
146
-	nsis/infblock.c \
147 144
 	nsis/nsis_bzlib.h \
148
-	nsis/nsis_zconf.h \
149
-	nsis/nsis_zlib.h \
150
-	nsis/nsis_zutil.h \
151 145
 	nsis/nulsft.c \
152 146
 	nsis/nulsft.h \
153 147
 	pdf.c \
... ...
@@ -189,7 +183,8 @@ libclamav_la_SOURCES = \
189 189
 	dconf.c \
190 190
 	dconf.h \
191 191
 	lockdb.c \
192
-	lockdb.h
192
+	lockdb.h \
193
+	lzma_iface.c
193 194
 
194 195
 lib_LTLIBRARIES = libclamav.la
195 196
 EXTRA_DIST = regex/engine.c
... ...
@@ -76,7 +76,7 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
76 76
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
77 77
 libLTLIBRARIES_INSTALL = $(INSTALL)
78 78
 LTLIBRARIES = $(lib_LTLIBRARIES)
79
-libclamav_la_DEPENDENCIES =
79
+libclamav_la_DEPENDENCIES = lzma/liblzma.la
80 80
 am_libclamav_la_OBJECTS = matcher-ac.lo matcher-bm.lo matcher.lo \
81 81
 	md5.lo others.lo readdb.lo cvd.lo dsig.lo str.lo scanners.lo \
82 82
 	filetypes.lo rtf.lo blob.lo mbox.lo message.lo snprintf.lo \
... ...
@@ -87,11 +87,10 @@ am_libclamav_la_OBJECTS = matcher-ac.lo matcher-bm.lo matcher.lo \
87 87
 	is_tar.lo tnef.lo autoit.lo strlcpy.lo regcomp.lo regerror.lo \
88 88
 	regexec.lo regfree.lo unrar15.lo unrarvm.lo unrar.lo \
89 89
 	unrarfilter.lo unrarppm.lo unrar20.lo unrarcmd.lo unarj.lo \
90
-	LZMADecode.lo bzlib.lo infblock.lo nulsft.lo pdf.lo spin.lo \
91
-	yc.lo elf.lo sis.lo uuencode.lo pst.lo phishcheck.lo \
92
-	phish_domaincheck_db.lo phish_whitelist.lo regex_list.lo \
93
-	sha256.lo mspack.lo cab.lo entconv.lo hashtab.lo dconf.lo \
94
-	lockdb.lo
90
+	bzlib.lo nulsft.lo pdf.lo spin.lo yc.lo elf.lo sis.lo \
91
+	uuencode.lo pst.lo phishcheck.lo phish_domaincheck_db.lo \
92
+	phish_whitelist.lo regex_list.lo sha256.lo mspack.lo cab.lo \
93
+	entconv.lo hashtab.lo dconf.lo lockdb.lo lzma_iface.lo
95 94
 libclamav_la_OBJECTS = $(am_libclamav_la_OBJECTS)
96 95
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
97 96
 depcomp = $(SHELL) $(top_srcdir)/depcomp
... ...
@@ -106,10 +105,17 @@ LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
106 106
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
107 107
 SOURCES = $(libclamav_la_SOURCES)
108 108
 DIST_SOURCES = $(libclamav_la_SOURCES)
109
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
110
+	html-recursive info-recursive install-data-recursive \
111
+	install-exec-recursive install-info-recursive \
112
+	install-recursive installcheck-recursive installdirs-recursive \
113
+	pdf-recursive ps-recursive uninstall-info-recursive \
114
+	uninstall-recursive
109 115
 includeHEADERS_INSTALL = $(INSTALL_HEADER)
110 116
 HEADERS = $(include_HEADERS)
111 117
 ETAGS = etags
112 118
 CTAGS = ctags
119
+DIST_SUBDIRS = $(SUBDIRS)
113 120
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
114 121
 ACLOCAL = @ACLOCAL@
115 122
 AMDEP_FALSE = @AMDEP_FALSE@
... ...
@@ -237,8 +243,9 @@ target_alias = @target_alias@
237 237
 target_cpu = @target_cpu@
238 238
 target_os = @target_os@
239 239
 target_vendor = @target_vendor@
240
-INCLUDES = -I$(top_srcdir) -I@srcdir@/unrar -I@srcdir@/nsis
241
-libclamav_la_LIBADD = @LIBCLAMAV_LIBS@ @THREAD_LIBS@
240
+SUBDIRS = lzma .
241
+INCLUDES = -I$(top_srcdir) -I@srcdir@/unrar -I@srcdir@/nsis -I@srcdir@/lzma
242
+libclamav_la_LIBADD = @LIBCLAMAV_LIBS@ @THREAD_LIBS@ lzma/liblzma.la
242 243
 libclamav_la_LDFLAGS = @TH_SAFE@ -version-info @LIBCLAMAV_VERSION@ -no-undefined
243 244
 include_HEADERS = clamav.h
244 245
 libclamav_la_SOURCES = \
... ...
@@ -354,15 +361,9 @@ libclamav_la_SOURCES = \
354 354
 	unrar/unrarppm.h \
355 355
 	unarj.c \
356 356
 	unarj.h \
357
-	nsis/LZMADecode.c \
358
-	nsis/LZMADecode.h \
359 357
 	nsis/bzlib.c \
360 358
 	nsis/bzlib_private.h \
361
-	nsis/infblock.c \
362 359
 	nsis/nsis_bzlib.h \
363
-	nsis/nsis_zconf.h \
364
-	nsis/nsis_zlib.h \
365
-	nsis/nsis_zutil.h \
366 360
 	nsis/nulsft.c \
367 361
 	nsis/nulsft.h \
368 362
 	pdf.c \
... ...
@@ -404,11 +405,12 @@ libclamav_la_SOURCES = \
404 404
 	dconf.c \
405 405
 	dconf.h \
406 406
 	lockdb.c \
407
-	lockdb.h
407
+	lockdb.h \
408
+	lzma_iface.c
408 409
 
409 410
 lib_LTLIBRARIES = libclamav.la
410 411
 EXTRA_DIST = regex/engine.c
411
-all: all-am
412
+all: all-recursive
412 413
 
413 414
 .SUFFIXES:
414 415
 .SUFFIXES: .c .lo .o .obj
... ...
@@ -477,7 +479,6 @@ mostlyclean-compile:
477 477
 distclean-compile:
478 478
 	-rm -f *.tab.c
479 479
 
480
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LZMADecode.Plo@am__quote@
481 480
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aspack.Plo@am__quote@
482 481
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/autoit.Plo@am__quote@
483 482
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binhex.Plo@am__quote@
... ...
@@ -494,10 +495,10 @@ distclean-compile:
494 494
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsg.Plo@am__quote@
495 495
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashtab.Plo@am__quote@
496 496
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmlnorm.Plo@am__quote@
497
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/infblock.Plo@am__quote@
498 497
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_tar.Plo@am__quote@
499 498
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line.Plo@am__quote@
500 499
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lockdb.Plo@am__quote@
500
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzma_iface.Plo@am__quote@
501 501
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/matcher-ac.Plo@am__quote@
502 502
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/matcher-bm.Plo@am__quote@
503 503
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/matcher.Plo@am__quote@
... ...
@@ -660,13 +661,6 @@ unrarcmd.lo: unrar/unrarcmd.c
660 660
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
661 661
 @am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o unrarcmd.lo `test -f 'unrar/unrarcmd.c' || echo '$(srcdir)/'`unrar/unrarcmd.c
662 662
 
663
-LZMADecode.lo: nsis/LZMADecode.c
664
-@am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT LZMADecode.lo -MD -MP -MF "$(DEPDIR)/LZMADecode.Tpo" -c -o LZMADecode.lo `test -f 'nsis/LZMADecode.c' || echo '$(srcdir)/'`nsis/LZMADecode.c; \
665
-@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/LZMADecode.Tpo" "$(DEPDIR)/LZMADecode.Plo"; else rm -f "$(DEPDIR)/LZMADecode.Tpo"; exit 1; fi
666
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='nsis/LZMADecode.c' object='LZMADecode.lo' libtool=yes @AMDEPBACKSLASH@
667
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
668
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o LZMADecode.lo `test -f 'nsis/LZMADecode.c' || echo '$(srcdir)/'`nsis/LZMADecode.c
669
-
670 663
 bzlib.lo: nsis/bzlib.c
671 664
 @am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bzlib.lo -MD -MP -MF "$(DEPDIR)/bzlib.Tpo" -c -o bzlib.lo `test -f 'nsis/bzlib.c' || echo '$(srcdir)/'`nsis/bzlib.c; \
672 665
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/bzlib.Tpo" "$(DEPDIR)/bzlib.Plo"; else rm -f "$(DEPDIR)/bzlib.Tpo"; exit 1; fi
... ...
@@ -674,13 +668,6 @@ bzlib.lo: nsis/bzlib.c
674 674
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
675 675
 @am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bzlib.lo `test -f 'nsis/bzlib.c' || echo '$(srcdir)/'`nsis/bzlib.c
676 676
 
677
-infblock.lo: nsis/infblock.c
678
-@am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT infblock.lo -MD -MP -MF "$(DEPDIR)/infblock.Tpo" -c -o infblock.lo `test -f 'nsis/infblock.c' || echo '$(srcdir)/'`nsis/infblock.c; \
679
-@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/infblock.Tpo" "$(DEPDIR)/infblock.Plo"; else rm -f "$(DEPDIR)/infblock.Tpo"; exit 1; fi
680
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='nsis/infblock.c' object='infblock.lo' libtool=yes @AMDEPBACKSLASH@
681
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
682
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o infblock.lo `test -f 'nsis/infblock.c' || echo '$(srcdir)/'`nsis/infblock.c
683
-
684 677
 nulsft.lo: nsis/nulsft.c
685 678
 @am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nulsft.lo -MD -MP -MF "$(DEPDIR)/nulsft.Tpo" -c -o nulsft.lo `test -f 'nsis/nulsft.c' || echo '$(srcdir)/'`nsis/nulsft.c; \
686 679
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/nulsft.Tpo" "$(DEPDIR)/nulsft.Plo"; else rm -f "$(DEPDIR)/nulsft.Tpo"; exit 1; fi
... ...
@@ -715,6 +702,77 @@ uninstall-includeHEADERS:
715 715
 	  rm -f "$(DESTDIR)$(includedir)/$$f"; \
716 716
 	done
717 717
 
718
+# This directory's subdirectories are mostly independent; you can cd
719
+# into them and run `make' without going through this Makefile.
720
+# To change the values of `make' variables: instead of editing Makefiles,
721
+# (1) if the variable is set in `config.status', edit `config.status'
722
+#     (which will cause the Makefiles to be regenerated when you run `make');
723
+# (2) otherwise, pass the desired values on the `make' command line.
724
+$(RECURSIVE_TARGETS):
725
+	@failcom='exit 1'; \
726
+	for f in x $$MAKEFLAGS; do \
727
+	  case $$f in \
728
+	    *=* | --[!k]*);; \
729
+	    *k*) failcom='fail=yes';; \
730
+	  esac; \
731
+	done; \
732
+	dot_seen=no; \
733
+	target=`echo $@ | sed s/-recursive//`; \
734
+	list='$(SUBDIRS)'; for subdir in $$list; do \
735
+	  echo "Making $$target in $$subdir"; \
736
+	  if test "$$subdir" = "."; then \
737
+	    dot_seen=yes; \
738
+	    local_target="$$target-am"; \
739
+	  else \
740
+	    local_target="$$target"; \
741
+	  fi; \
742
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
743
+	  || eval $$failcom; \
744
+	done; \
745
+	if test "$$dot_seen" = "no"; then \
746
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
747
+	fi; test -z "$$fail"
748
+
749
+mostlyclean-recursive clean-recursive distclean-recursive \
750
+maintainer-clean-recursive:
751
+	@failcom='exit 1'; \
752
+	for f in x $$MAKEFLAGS; do \
753
+	  case $$f in \
754
+	    *=* | --[!k]*);; \
755
+	    *k*) failcom='fail=yes';; \
756
+	  esac; \
757
+	done; \
758
+	dot_seen=no; \
759
+	case "$@" in \
760
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
761
+	  *) list='$(SUBDIRS)' ;; \
762
+	esac; \
763
+	rev=''; for subdir in $$list; do \
764
+	  if test "$$subdir" = "."; then :; else \
765
+	    rev="$$subdir $$rev"; \
766
+	  fi; \
767
+	done; \
768
+	rev="$$rev ."; \
769
+	target=`echo $@ | sed s/-recursive//`; \
770
+	for subdir in $$rev; do \
771
+	  echo "Making $$target in $$subdir"; \
772
+	  if test "$$subdir" = "."; then \
773
+	    local_target="$$target-am"; \
774
+	  else \
775
+	    local_target="$$target"; \
776
+	  fi; \
777
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
778
+	  || eval $$failcom; \
779
+	done && test -z "$$fail"
780
+tags-recursive:
781
+	list='$(SUBDIRS)'; for subdir in $$list; do \
782
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
783
+	done
784
+ctags-recursive:
785
+	list='$(SUBDIRS)'; for subdir in $$list; do \
786
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
787
+	done
788
+
718 789
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
719 790
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
720 791
 	unique=`for i in $$list; do \
... ...
@@ -725,10 +783,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
725 725
 	mkid -fID $$unique
726 726
 tags: TAGS
727 727
 
728
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
728
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
729 729
 		$(TAGS_FILES) $(LISP)
730 730
 	tags=; \
731 731
 	here=`pwd`; \
732
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
733
+	  include_option=--etags-include; \
734
+	  empty_fix=.; \
735
+	else \
736
+	  include_option=--include; \
737
+	  empty_fix=; \
738
+	fi; \
739
+	list='$(SUBDIRS)'; for subdir in $$list; do \
740
+	  if test "$$subdir" = .; then :; else \
741
+	    test ! -f $$subdir/TAGS || \
742
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
743
+	  fi; \
744
+	done; \
732 745
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
733 746
 	unique=`for i in $$list; do \
734 747
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
... ...
@@ -741,7 +812,7 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
741 741
 	    $$tags $$unique; \
742 742
 	fi
743 743
 ctags: CTAGS
744
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
744
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
745 745
 		$(TAGS_FILES) $(LISP)
746 746
 	tags=; \
747 747
 	here=`pwd`; \
... ...
@@ -791,22 +862,38 @@ distdir: $(DISTFILES)
791 791
 	    || exit 1; \
792 792
 	  fi; \
793 793
 	done
794
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
795
+	  if test "$$subdir" = .; then :; else \
796
+	    test -d "$(distdir)/$$subdir" \
797
+	    || $(mkdir_p) "$(distdir)/$$subdir" \
798
+	    || exit 1; \
799
+	    distdir=`$(am__cd) $(distdir) && pwd`; \
800
+	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
801
+	    (cd $$subdir && \
802
+	      $(MAKE) $(AM_MAKEFLAGS) \
803
+	        top_distdir="$$top_distdir" \
804
+	        distdir="$$distdir/$$subdir" \
805
+	        distdir) \
806
+	      || exit 1; \
807
+	  fi; \
808
+	done
794 809
 check-am: all-am
795
-check: check-am
810
+check: check-recursive
796 811
 all-am: Makefile $(LTLIBRARIES) $(HEADERS)
797
-installdirs:
812
+installdirs: installdirs-recursive
813
+installdirs-am:
798 814
 	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
799 815
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
800 816
 	done
801
-install: install-am
802
-install-exec: install-exec-am
803
-install-data: install-data-am
804
-uninstall: uninstall-am
817
+install: install-recursive
818
+install-exec: install-exec-recursive
819
+install-data: install-data-recursive
820
+uninstall: uninstall-recursive
805 821
 
806 822
 install-am: all-am
807 823
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
808 824
 
809
-installcheck: installcheck-am
825
+installcheck: installcheck-recursive
810 826
 install-strip:
811 827
 	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
812 828
 	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
... ...
@@ -822,24 +909,24 @@ distclean-generic:
822 822
 maintainer-clean-generic:
823 823
 	@echo "This command is intended for maintainers to use"
824 824
 	@echo "it deletes files that may require special tools to rebuild."
825
-clean: clean-am
825
+clean: clean-recursive
826 826
 
827 827
 clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
828 828
 	mostlyclean-am
829 829
 
830
-distclean: distclean-am
830
+distclean: distclean-recursive
831 831
 	-rm -rf ./$(DEPDIR)
832 832
 	-rm -f Makefile
833 833
 distclean-am: clean-am distclean-compile distclean-generic \
834 834
 	distclean-libtool distclean-tags
835 835
 
836
-dvi: dvi-am
836
+dvi: dvi-recursive
837 837
 
838 838
 dvi-am:
839 839
 
840
-html: html-am
840
+html: html-recursive
841 841
 
842
-info: info-am
842
+info: info-recursive
843 843
 
844 844
 info-am:
845 845
 
... ...
@@ -847,44 +934,49 @@ install-data-am: install-includeHEADERS
847 847
 
848 848
 install-exec-am: install-libLTLIBRARIES
849 849
 
850
-install-info: install-info-am
850
+install-info: install-info-recursive
851 851
 
852 852
 install-man:
853 853
 
854 854
 installcheck-am:
855 855
 
856
-maintainer-clean: maintainer-clean-am
856
+maintainer-clean: maintainer-clean-recursive
857 857
 	-rm -rf ./$(DEPDIR)
858 858
 	-rm -f Makefile
859 859
 maintainer-clean-am: distclean-am maintainer-clean-generic
860 860
 
861
-mostlyclean: mostlyclean-am
861
+mostlyclean: mostlyclean-recursive
862 862
 
863 863
 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
864 864
 	mostlyclean-libtool
865 865
 
866
-pdf: pdf-am
866
+pdf: pdf-recursive
867 867
 
868 868
 pdf-am:
869 869
 
870
-ps: ps-am
870
+ps: ps-recursive
871 871
 
872 872
 ps-am:
873 873
 
874 874
 uninstall-am: uninstall-includeHEADERS uninstall-info-am \
875 875
 	uninstall-libLTLIBRARIES
876 876
 
877
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
878
-	clean-libLTLIBRARIES clean-libtool ctags distclean \
877
+uninstall-info: uninstall-info-recursive
878
+
879
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
880
+	clean clean-generic clean-libLTLIBRARIES clean-libtool \
881
+	clean-recursive ctags ctags-recursive distclean \
879 882
 	distclean-compile distclean-generic distclean-libtool \
880
-	distclean-tags distdir dvi dvi-am html html-am info info-am \
881
-	install install-am install-data install-data-am install-exec \
882
-	install-exec-am install-includeHEADERS install-info \
883
-	install-info-am install-libLTLIBRARIES install-man \
884
-	install-strip installcheck installcheck-am installdirs \
885
-	maintainer-clean maintainer-clean-generic mostlyclean \
886
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
887
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
883
+	distclean-recursive distclean-tags distdir dvi dvi-am html \
884
+	html-am info info-am install install-am install-data \
885
+	install-data-am install-exec install-exec-am \
886
+	install-includeHEADERS install-info install-info-am \
887
+	install-libLTLIBRARIES install-man install-strip installcheck \
888
+	installcheck-am installdirs installdirs-am maintainer-clean \
889
+	maintainer-clean-generic maintainer-clean-recursive \
890
+	mostlyclean mostlyclean-compile mostlyclean-generic \
891
+	mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \
892
+	tags tags-recursive uninstall uninstall-am \
888 893
 	uninstall-includeHEADERS uninstall-info-am \
889 894
 	uninstall-libLTLIBRARIES
890 895
 
... ...
@@ -85,14 +85,13 @@ extern "C"
85 85
 #define CL_SCAN_MAILURL		    0x80
86 86
 #define CL_SCAN_BLOCKMAX	    0x100
87 87
 #define CL_SCAN_ALGORITHMIC	    0x200
88
-#define CL_SCAN_PHISHING_DOMAINLIST 0x400
89 88
 #define CL_SCAN_PHISHING_BLOCKSSL   0x800 /* ssl mismatches, not ssl by itself*/
90 89
 #define CL_SCAN_PHISHING_BLOCKCLOAK 0x1000
91 90
 #define CL_SCAN_ELF		    0x2000
92 91
 #define CL_SCAN_PDF		    0x4000
93 92
 
94 93
 /* recommended scan settings */
95
-#define CL_SCAN_STDOPT		(CL_SCAN_ARCHIVE | CL_SCAN_MAIL | CL_SCAN_OLE2 | CL_SCAN_HTML | CL_SCAN_PE | CL_SCAN_ALGORITHMIC | CL_SCAN_ELF | CL_SCAN_PHISHING_DOMAINLIST) 
94
+#define CL_SCAN_STDOPT		(CL_SCAN_ARCHIVE | CL_SCAN_MAIL | CL_SCAN_OLE2 | CL_SCAN_HTML | CL_SCAN_PE | CL_SCAN_ALGORITHMIC | CL_SCAN_ELF)
96 95
 
97 96
 /* aliases for backward compatibility */
98 97
 #define CL_RAW		CL_SCAN_RAW
99 98
new file mode 100644
... ...
@@ -0,0 +1,521 @@
0
+/*
1
+  LzmaStateDecode.c
2
+  LZMA Decoder (State version)
3
+  
4
+  LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5
+  http://www.7-zip.org/
6
+
7
+  LZMA SDK is licensed under two licenses:
8
+  1) GNU Lesser General Public License (GNU LGPL)
9
+  2) Common Public License (CPL)
10
+  It means that you can select one of these two licenses and 
11
+  follow rules of that license.
12
+
13
+  SPECIAL EXCEPTION:
14
+  Igor Pavlov, as the author of this Code, expressly permits you to 
15
+  statically or dynamically link your Code (or bind by name) to the 
16
+  interfaces of this file without subjecting your linked Code to the 
17
+  terms of the CPL or GNU LGPL. Any modifications or additions 
18
+  to this file, however, are subject to the LGPL or CPL terms.
19
+*/
20
+
21
+#include "LzmaStateDecode.h"
22
+
23
+#define kNumTopBits 24
24
+#define kTopValue ((UInt32)1 << kNumTopBits)
25
+
26
+#define kNumBitModelTotalBits 11
27
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
28
+#define kNumMoveBits 5
29
+
30
+#define RC_READ_BYTE (*Buffer++)
31
+
32
+#define RC_INIT Code = 0; Range = 0xFFFFFFFF; \
33
+  { int i; for(i = 0; i < 5; i++) { Code = (Code << 8) | RC_READ_BYTE; }}
34
+
35
+#define RC_NORMALIZE if (Range < kTopValue) { Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
36
+
37
+#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
38
+#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
39
+#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
40
+
41
+#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
42
+  { UpdateBit0(p); mi <<= 1; A0; } else \
43
+  { UpdateBit1(p); mi = (mi + mi) + 1; A1; } 
44
+  
45
+#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)               
46
+
47
+#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
48
+  { int i = numLevels; res = 1; \
49
+  do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
50
+  res -= (1 << numLevels); }
51
+
52
+
53
+#define kNumPosBitsMax 4
54
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
55
+
56
+#define kLenNumLowBits 3
57
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
58
+#define kLenNumMidBits 3
59
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
60
+#define kLenNumHighBits 8
61
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
62
+
63
+#define LenChoice 0
64
+#define LenChoice2 (LenChoice + 1)
65
+#define LenLow (LenChoice2 + 1)
66
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
67
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
68
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols) 
69
+
70
+
71
+#define kNumStates 12
72
+#define kNumLitStates 7
73
+
74
+#define kStartPosModelIndex 4
75
+#define kEndPosModelIndex 14
76
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
77
+
78
+#define kNumPosSlotBits 6
79
+#define kNumLenToPosStates 4
80
+
81
+#define kNumAlignBits 4
82
+#define kAlignTableSize (1 << kNumAlignBits)
83
+
84
+#define kMatchMinLen 2
85
+
86
+#define IsMatch 0
87
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
88
+#define IsRepG0 (IsRep + kNumStates)
89
+#define IsRepG1 (IsRepG0 + kNumStates)
90
+#define IsRepG2 (IsRepG1 + kNumStates)
91
+#define IsRep0Long (IsRepG2 + kNumStates)
92
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
93
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
94
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
95
+#define LenCoder (Align + kAlignTableSize)
96
+#define RepLenCoder (LenCoder + kNumLenProbs)
97
+#define Literal (RepLenCoder + kNumLenProbs)
98
+
99
+#if Literal != LZMA_BASE_SIZE
100
+StopCompilingDueBUG
101
+#endif
102
+
103
+/* kRequiredInBufferSize = number of required input bytes for worst case: 
104
+   longest match with longest distance.
105
+   kLzmaInBufferSize must be larger than kRequiredInBufferSize 
106
+   23 bits = 2 (match select) + 10 (len) + 6 (distance) + 4(align) + 1 (RC_NORMALIZE)
107
+*/
108
+
109
+#define kRequiredInBufferSize ((23 * (kNumBitModelTotalBits - kNumMoveBits + 1) + 26 + 9) / 8)
110
+
111
+#define kLzmaStreamWasFinishedId (-1)
112
+
113
+int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
114
+{
115
+  unsigned char prop0;
116
+  if (size < LZMA_PROPERTIES_SIZE)
117
+    return LZMA_RESULT_DATA_ERROR;
118
+  prop0 = propsData[0];
119
+  if (prop0 >= (9 * 5 * 5))
120
+    return LZMA_RESULT_DATA_ERROR;
121
+  {
122
+    for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
123
+    for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
124
+    propsRes->lc = prop0;
125
+    /*
126
+    unsigned char remainder = (unsigned char)(prop0 / 9);
127
+    propsRes->lc = prop0 % 9;
128
+    propsRes->pb = remainder / 5;
129
+    propsRes->lp = remainder % 5;
130
+    */
131
+  }
132
+
133
+  {
134
+    int i;
135
+    propsRes->DictionarySize = 0;
136
+    for (i = 0; i < 4; i++)
137
+      propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
138
+    if (propsRes->DictionarySize == 0)
139
+      propsRes->DictionarySize = 1;
140
+    return LZMA_RESULT_OK;
141
+  }
142
+}
143
+
144
+int LzmaDecode(
145
+    CLzmaDecoderState *vs,
146
+    const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
147
+    unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed,
148
+    int finishDecoding)
149
+{
150
+  UInt32 Range = vs->Range;
151
+  UInt32 Code = vs->Code;
152
+
153
+  unsigned char *Buffer = vs->Buffer;
154
+  int BufferSize = vs->BufferSize; /* don't change it to unsigned int */
155
+  CProb *p = vs->Probs;
156
+
157
+  int state = vs->State;
158
+  unsigned char previousByte;
159
+  UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
160
+  SizeT nowPos = 0;
161
+  UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
162
+  UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
163
+  int lc = vs->Properties.lc;
164
+  int len = vs->RemainLen;
165
+  UInt32 globalPos = vs->GlobalPos;
166
+  UInt32 distanceLimit = vs->DistanceLimit;
167
+
168
+  unsigned char *dictionary = vs->Dictionary;
169
+  UInt32 dictionarySize = vs->Properties.DictionarySize;
170
+  UInt32 dictionaryPos = vs->DictionaryPos;
171
+
172
+  unsigned char tempDictionary[4];
173
+
174
+  (*inSizeProcessed) = 0;
175
+  (*outSizeProcessed) = 0;
176
+  if (len == kLzmaStreamWasFinishedId)
177
+    return LZMA_RESULT_OK;
178
+
179
+  if (dictionarySize == 0)
180
+  {
181
+    dictionary = tempDictionary;
182
+    dictionarySize = 1;
183
+    tempDictionary[0] = vs->TempDictionary[0];
184
+  }
185
+
186
+  if (len == kLzmaNeedInitId)
187
+  {
188
+    while (inSize > 0 && BufferSize < kLzmaInBufferSize)
189
+    {
190
+      Buffer[BufferSize++] = *inStream++;
191
+      (*inSizeProcessed)++;
192
+      inSize--;
193
+    }
194
+    if (BufferSize < 5)
195
+    {
196
+      vs->BufferSize = BufferSize;
197
+      return finishDecoding ? LZMA_RESULT_DATA_ERROR : LZMA_RESULT_OK;
198
+    }
199
+    {
200
+      UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
201
+      UInt32 i;
202
+      for (i = 0; i < numProbs; i++)
203
+        p[i] = kBitModelTotal >> 1; 
204
+      rep0 = rep1 = rep2 = rep3 = 1;
205
+      state = 0;
206
+      globalPos = 0;
207
+      distanceLimit = 0;
208
+      dictionaryPos = 0;
209
+      dictionary[dictionarySize - 1] = 0;
210
+      RC_INIT;
211
+    }
212
+    len = 0;
213
+  }
214
+  while(len != 0 && nowPos < outSize)
215
+  {
216
+    UInt32 pos = dictionaryPos - rep0;
217
+    if (pos >= dictionarySize)
218
+      pos += dictionarySize;
219
+    outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
220
+    if (++dictionaryPos == dictionarySize)
221
+      dictionaryPos = 0;
222
+    len--;
223
+  }
224
+  if (dictionaryPos == 0)
225
+    previousByte = dictionary[dictionarySize - 1];
226
+  else
227
+    previousByte = dictionary[dictionaryPos - 1];
228
+
229
+  while(1)
230
+  {
231
+    int bufferPos = (int)(Buffer - vs->Buffer);
232
+    if (BufferSize - bufferPos < kRequiredInBufferSize)
233
+    {
234
+      int i;
235
+      BufferSize -= bufferPos;
236
+      if (BufferSize < 0)
237
+        return LZMA_RESULT_DATA_ERROR;
238
+      for (i = 0; i < BufferSize; i++)
239
+        vs->Buffer[i] = Buffer[i];
240
+      Buffer = vs->Buffer;
241
+      while (inSize > 0 && BufferSize < kLzmaInBufferSize)
242
+      {
243
+        Buffer[BufferSize++] = *inStream++;
244
+        (*inSizeProcessed)++;
245
+        inSize--;
246
+      }
247
+      if (BufferSize < kRequiredInBufferSize && !finishDecoding)
248
+        break;
249
+    }
250
+    if (nowPos >= outSize)
251
+      break;
252
+    {
253
+    CProb *prob;
254
+    UInt32 bound;
255
+    int posState = (int)((nowPos + globalPos) & posStateMask);
256
+
257
+    prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
258
+    IfBit0(prob)
259
+    {
260
+      int symbol = 1;
261
+      UpdateBit0(prob)
262
+      prob = p + Literal + (LZMA_LIT_SIZE * 
263
+        ((((nowPos + globalPos)& literalPosMask) << lc) + (previousByte >> (8 - lc))));
264
+
265
+      if (state >= kNumLitStates)
266
+      {
267
+        int matchByte;
268
+        UInt32 pos = dictionaryPos - rep0;
269
+        if (pos >= dictionarySize)
270
+          pos += dictionarySize;
271
+        matchByte = dictionary[pos];
272
+        do
273
+        {
274
+          int bit;
275
+          CProb *probLit;
276
+          matchByte <<= 1;
277
+          bit = (matchByte & 0x100);
278
+          probLit = prob + 0x100 + bit + symbol;
279
+          RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
280
+        }
281
+        while (symbol < 0x100);
282
+      }
283
+      while (symbol < 0x100)
284
+      {
285
+        CProb *probLit = prob + symbol;
286
+        RC_GET_BIT(probLit, symbol)
287
+      }
288
+      previousByte = (unsigned char)symbol;
289
+
290
+      outStream[nowPos++] = previousByte;
291
+      if (distanceLimit < dictionarySize)
292
+        distanceLimit++;
293
+
294
+      dictionary[dictionaryPos] = previousByte;
295
+      if (++dictionaryPos == dictionarySize)
296
+        dictionaryPos = 0;
297
+      if (state < 4) state = 0;
298
+      else if (state < 10) state -= 3;
299
+      else state -= 6;
300
+    }
301
+    else             
302
+    {
303
+      UpdateBit1(prob);
304
+      prob = p + IsRep + state;
305
+      IfBit0(prob)
306
+      {
307
+        UpdateBit0(prob);
308
+        rep3 = rep2;
309
+        rep2 = rep1;
310
+        rep1 = rep0;
311
+        state = state < kNumLitStates ? 0 : 3;
312
+        prob = p + LenCoder;
313
+      }
314
+      else
315
+      {
316
+        UpdateBit1(prob);
317
+        prob = p + IsRepG0 + state;
318
+        IfBit0(prob)
319
+        {
320
+          UpdateBit0(prob);
321
+          prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
322
+          IfBit0(prob)
323
+          {
324
+            UInt32 pos;
325
+            UpdateBit0(prob);
326
+            if (distanceLimit == 0)
327
+              return LZMA_RESULT_DATA_ERROR;
328
+            if (distanceLimit < dictionarySize)
329
+              distanceLimit++;
330
+            state = state < kNumLitStates ? 9 : 11;
331
+            pos = dictionaryPos - rep0;
332
+            if (pos >= dictionarySize)
333
+              pos += dictionarySize;
334
+            previousByte = dictionary[pos];
335
+            dictionary[dictionaryPos] = previousByte;
336
+            if (++dictionaryPos == dictionarySize)
337
+              dictionaryPos = 0;
338
+            outStream[nowPos++] = previousByte;
339
+            continue;
340
+          }
341
+          else
342
+          {
343
+            UpdateBit1(prob);
344
+          }
345
+        }
346
+        else
347
+        {
348
+          UInt32 distance;
349
+          UpdateBit1(prob);
350
+          prob = p + IsRepG1 + state;
351
+          IfBit0(prob)
352
+          {
353
+            UpdateBit0(prob);
354
+            distance = rep1;
355
+          }
356
+          else 
357
+          {
358
+            UpdateBit1(prob);
359
+            prob = p + IsRepG2 + state;
360
+            IfBit0(prob)
361
+            {
362
+              UpdateBit0(prob);
363
+              distance = rep2;
364
+            }
365
+            else
366
+            {
367
+              UpdateBit1(prob);
368
+              distance = rep3;
369
+              rep3 = rep2;
370
+            }
371
+            rep2 = rep1;
372
+          }
373
+          rep1 = rep0;
374
+          rep0 = distance;
375
+        }
376
+        state = state < kNumLitStates ? 8 : 11;
377
+        prob = p + RepLenCoder;
378
+      }
379
+      {
380
+        int numBits, offset;
381
+        CProb *probLen = prob + LenChoice;
382
+        IfBit0(probLen)
383
+        {
384
+          UpdateBit0(probLen);
385
+          probLen = prob + LenLow + (posState << kLenNumLowBits);
386
+          offset = 0;
387
+          numBits = kLenNumLowBits;
388
+        }
389
+        else
390
+        {
391
+          UpdateBit1(probLen);
392
+          probLen = prob + LenChoice2;
393
+          IfBit0(probLen)
394
+          {
395
+            UpdateBit0(probLen);
396
+            probLen = prob + LenMid + (posState << kLenNumMidBits);
397
+            offset = kLenNumLowSymbols;
398
+            numBits = kLenNumMidBits;
399
+          }
400
+          else
401
+          {
402
+            UpdateBit1(probLen);
403
+            probLen = prob + LenHigh;
404
+            offset = kLenNumLowSymbols + kLenNumMidSymbols;
405
+            numBits = kLenNumHighBits;
406
+          }
407
+        }
408
+        RangeDecoderBitTreeDecode(probLen, numBits, len);
409
+        len += offset;
410
+      }
411
+
412
+      if (state < 4)
413
+      {
414
+        int posSlot;
415
+        state += kNumLitStates;
416
+        prob = p + PosSlot +
417
+            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << 
418
+            kNumPosSlotBits);
419
+        RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
420
+        if (posSlot >= kStartPosModelIndex)
421
+        {
422
+          int numDirectBits = ((posSlot >> 1) - 1);
423
+          rep0 = (2 | ((UInt32)posSlot & 1));
424
+          if (posSlot < kEndPosModelIndex)
425
+          {
426
+            rep0 <<= numDirectBits;
427
+            prob = p + SpecPos + rep0 - posSlot - 1;
428
+          }
429
+          else
430
+          {
431
+            numDirectBits -= kNumAlignBits;
432
+            do
433
+            {
434
+              RC_NORMALIZE
435
+              Range >>= 1;
436
+              rep0 <<= 1;
437
+              if (Code >= Range)
438
+              {
439
+                Code -= Range;
440
+                rep0 |= 1;
441
+              }
442
+            }
443
+            while (--numDirectBits != 0);
444
+            prob = p + Align;
445
+            rep0 <<= kNumAlignBits;
446
+            numDirectBits = kNumAlignBits;
447
+          }
448
+          {
449
+            int i = 1;
450
+            int mi = 1;
451
+            do
452
+            {
453
+              CProb *prob3 = prob + mi;
454
+              RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
455
+              i <<= 1;
456
+            }
457
+            while(--numDirectBits != 0);
458
+          }
459
+        }
460
+        else
461
+          rep0 = posSlot;
462
+        if (++rep0 == (UInt32)(0))
463
+        {
464
+          /* it's for stream version */
465
+          len = kLzmaStreamWasFinishedId;
466
+          break;
467
+        }
468
+      }
469
+
470
+      len += kMatchMinLen;
471
+      if (rep0 > distanceLimit) 
472
+        return LZMA_RESULT_DATA_ERROR;
473
+      if (dictionarySize - distanceLimit > (UInt32)len)
474
+        distanceLimit += len;
475
+      else
476
+        distanceLimit = dictionarySize;
477
+
478
+      do
479
+      {
480
+        UInt32 pos = dictionaryPos - rep0;
481
+        if (pos >= dictionarySize)
482
+          pos += dictionarySize;
483
+        previousByte = dictionary[pos];
484
+        dictionary[dictionaryPos] = previousByte;
485
+        if (++dictionaryPos == dictionarySize)
486
+          dictionaryPos = 0;
487
+        len--;
488
+        outStream[nowPos++] = previousByte;
489
+      }
490
+      while(len != 0 && nowPos < outSize);
491
+    }
492
+    }
493
+  }
494
+  RC_NORMALIZE;
495
+
496
+  BufferSize -= (int)(Buffer - vs->Buffer);
497
+  if (BufferSize < 0)
498
+    return LZMA_RESULT_DATA_ERROR;
499
+  {
500
+    int i;
501
+    for (i = 0; i < BufferSize; i++)
502
+      vs->Buffer[i] = Buffer[i];
503
+  }
504
+  vs->BufferSize = BufferSize;
505
+  vs->Range = Range;
506
+  vs->Code = Code;
507
+  vs->DictionaryPos = dictionaryPos;
508
+  vs->GlobalPos = (UInt32)(globalPos + nowPos);
509
+  vs->DistanceLimit = distanceLimit;
510
+  vs->Reps[0] = rep0;
511
+  vs->Reps[1] = rep1;
512
+  vs->Reps[2] = rep2;
513
+  vs->Reps[3] = rep3;
514
+  vs->State = state;
515
+  vs->RemainLen = len;
516
+  vs->TempDictionary[0] = tempDictionary[0];
517
+
518
+  (*outSizeProcessed) = nowPos;
519
+  return LZMA_RESULT_OK;
520
+}
0 521
new file mode 100644
... ...
@@ -0,0 +1,96 @@
0
+/* 
1
+  LzmaStateDecode.h
2
+  LZMA Decoder interface (State version)
3
+
4
+  LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5
+  http://www.7-zip.org/
6
+
7
+  LZMA SDK is licensed under two licenses:
8
+  1) GNU Lesser General Public License (GNU LGPL)
9
+  2) Common Public License (CPL)
10
+  It means that you can select one of these two licenses and 
11
+  follow rules of that license.
12
+
13
+  SPECIAL EXCEPTION:
14
+  Igor Pavlov, as the author of this code, expressly permits you to 
15
+  statically or dynamically link your code (or bind by name) to the 
16
+  interfaces of this file without subjecting your linked code to the 
17
+  terms of the CPL or GNU LGPL. Any modifications or additions 
18
+  to this file, however, are subject to the LGPL or CPL terms.
19
+*/
20
+
21
+#ifndef __LZMASTATEDECODE_H
22
+#define __LZMASTATEDECODE_H
23
+
24
+#include "LzmaTypes.h"
25
+
26
+/* #define _LZMA_PROB32 */
27
+/* It can increase speed on some 32-bit CPUs, 
28
+   but memory usage will be doubled in that case */
29
+
30
+#ifdef _LZMA_PROB32
31
+#define CProb UInt32
32
+#else
33
+#define CProb UInt16
34
+#endif
35
+
36
+#define LZMA_RESULT_OK 0
37
+#define LZMA_RESULT_DATA_ERROR 1
38
+
39
+#define LZMA_BASE_SIZE 1846
40
+#define LZMA_LIT_SIZE 768
41
+
42
+#define LZMA_PROPERTIES_SIZE 5
43
+
44
+typedef struct _CLzmaProperties
45
+{
46
+  int lc;
47
+  int lp;
48
+  int pb;
49
+  UInt32 DictionarySize;
50
+}CLzmaProperties;
51
+
52
+int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
53
+
54
+#define LzmaGetNumProbs(lzmaProps) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((lzmaProps)->lc + (lzmaProps)->lp)))
55
+
56
+#define kLzmaInBufferSize 64   /* don't change it. it must be larger than kRequiredInBufferSize */
57
+
58
+#define kLzmaNeedInitId (-2)
59
+
60
+typedef struct _CLzmaDecoderState
61
+{
62
+  CLzmaProperties Properties;
63
+  CProb *Probs;
64
+  unsigned char *Dictionary;
65
+
66
+  unsigned char Buffer[kLzmaInBufferSize];
67
+  int BufferSize;
68
+
69
+  UInt32 Range;
70
+  UInt32 Code;
71
+  UInt32 DictionaryPos;
72
+  UInt32 GlobalPos;
73
+  UInt32 DistanceLimit;
74
+  UInt32 Reps[4];
75
+  int State;
76
+  int RemainLen;  /* -2: decoder needs internal initialization
77
+                     -1: stream was finished, 
78
+                      0: ok
79
+                    > 0: need to write RemainLen bytes as match Reps[0],
80
+                  */
81
+  unsigned char TempDictionary[4];  /* it's required when DictionarySize = 0 */
82
+} CLzmaDecoderState;
83
+
84
+#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; (vs)->BufferSize = 0; }
85
+
86
+/* LzmaDecode: decoding from input stream to output stream.
87
+  If finishDecoding != 0, then there are no more bytes in input stream
88
+  after inStream[inSize - 1]. */
89
+
90
+int LzmaDecode(CLzmaDecoderState *vs,
91
+    const unsigned char *inStream, SizeT inSize,  SizeT *inSizeProcessed,
92
+    unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed,
93
+    int finishDecoding);
94
+
95
+#endif
0 96
new file mode 100644
... ...
@@ -0,0 +1,32 @@
0
+/* 
1
+LzmaTypes.h 
2
+
3
+Types for LZMA Decoder
4
+
5
+This file written and distributed to public domain by Igor Pavlov.
6
+This file is part of LZMA SDK 4.40 (2006-05-01)
7
+*/
8
+
9
+#ifndef __LZMATYPES_H
10
+#define __LZMATYPES_H
11
+
12
+typedef unsigned char Byte;
13
+typedef unsigned short UInt16;
14
+
15
+#ifdef _LZMA_UINT32_IS_ULONG
16
+typedef unsigned long UInt32;
17
+#else
18
+typedef unsigned int UInt32;
19
+#endif
20
+
21
+/* #define _LZMA_SYSTEM_SIZE_T */
22
+/* Use system's size_t. You can use it to enable 64-bit sizes supporting */
23
+
24
+#ifdef _LZMA_SYSTEM_SIZE_T
25
+#include <stddef.h>
26
+typedef size_t SizeT;
27
+#else
28
+typedef UInt32 SizeT;
29
+#endif
30
+
31
+#endif
0 32
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+#
1
+#  Copyright (C) 2007 Sourcefire Inc.
2
+#  Author: aCaB <acab@clamav.net>
3
+#
4
+#  This program is free software; you can redistribute it and/or modify
5
+#  it under the terms of the GNU General Public License version 2 as
6
+#  published by the Free Software Foundation.
7
+#
8
+#  This program is distributed in the hope that it will be useful,
9
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
+#  GNU General Public License for more details.
12
+#
13
+#  You should have received a copy of the GNU General Public License
14
+#  along with this program; if not, write to the Free Software
15
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+#  MA 02110-1301, USA.
17
+#
18
+
19
+AM_CFLAGS = -fPIC -DPIC
20
+
21
+lib_LTLIBRARIES = liblzma.la
22
+liblzma_la_SOURCES = LzmaStateDecode.c
23
+liblzma_la_LDFLAGS = -static
24
+
0 25
new file mode 100644
... ...
@@ -0,0 +1,501 @@
0
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
1
+# @configure_input@
2
+
3
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4
+# 2003, 2004, 2005  Free Software Foundation, Inc.
5
+# This Makefile.in is free software; the Free Software Foundation
6
+# gives unlimited permission to copy and/or distribute it,
7
+# with or without modifications, as long as this notice is preserved.
8
+
9
+# This program is distributed in the hope that it will be useful,
10
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
+# PARTICULAR PURPOSE.
13
+
14
+@SET_MAKE@
15
+
16
+#
17
+#  Copyright (C) 2007 Sourcefire Inc.
18
+#  Author: aCaB <acab@clamav.net>
19
+#
20
+#  This program is free software; you can redistribute it and/or modify
21
+#  it under the terms of the GNU General Public License version 2 as
22
+#  published by the Free Software Foundation.
23
+#
24
+#  This program is distributed in the hope that it will be useful,
25
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
+#  GNU General Public License for more details.
28
+#
29
+#  You should have received a copy of the GNU General Public License
30
+#  along with this program; if not, write to the Free Software
31
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
32
+#  MA 02110-1301, USA.
33
+#
34
+
35
+srcdir = @srcdir@
36
+top_srcdir = @top_srcdir@
37
+VPATH = @srcdir@
38
+pkgdatadir = $(datadir)/@PACKAGE@
39
+pkglibdir = $(libdir)/@PACKAGE@
40
+pkgincludedir = $(includedir)/@PACKAGE@
41
+top_builddir = ../..
42
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
43
+INSTALL = @INSTALL@
44
+install_sh_DATA = $(install_sh) -c -m 644
45
+install_sh_PROGRAM = $(install_sh) -c
46
+install_sh_SCRIPT = $(install_sh) -c
47
+INSTALL_HEADER = $(INSTALL_DATA)
48
+transform = $(program_transform_name)
49
+NORMAL_INSTALL = :
50
+PRE_INSTALL = :
51
+POST_INSTALL = :
52
+NORMAL_UNINSTALL = :
53
+PRE_UNINSTALL = :
54
+POST_UNINSTALL = :
55
+build_triplet = @build@
56
+host_triplet = @host@
57
+target_triplet = @target@
58
+subdir = libclamav/lzma
59
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
60
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
61
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
62
+	$(top_srcdir)/configure.in
63
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
64
+	$(ACLOCAL_M4)
65
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
66
+CONFIG_HEADER = $(top_builddir)/clamav-config.h
67
+CONFIG_CLEAN_FILES =
68
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
69
+am__vpath_adj = case $$p in \
70
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
71
+    *) f=$$p;; \
72
+  esac;
73
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
74
+am__installdirs = "$(DESTDIR)$(libdir)"
75
+libLTLIBRARIES_INSTALL = $(INSTALL)
76
+LTLIBRARIES = $(lib_LTLIBRARIES)
77
+liblzma_la_LIBADD =
78
+am_liblzma_la_OBJECTS = LzmaStateDecode.lo
79
+liblzma_la_OBJECTS = $(am_liblzma_la_OBJECTS)
80
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
81
+depcomp = $(SHELL) $(top_srcdir)/depcomp
82
+am__depfiles_maybe = depfiles
83
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
84
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
85
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
86
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
87
+	$(AM_CFLAGS) $(CFLAGS)
88
+CCLD = $(CC)
89
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
90
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
91
+SOURCES = $(liblzma_la_SOURCES)
92
+DIST_SOURCES = $(liblzma_la_SOURCES)
93
+ETAGS = etags
94
+CTAGS = ctags
95
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
96
+ACLOCAL = @ACLOCAL@
97
+AMDEP_FALSE = @AMDEP_FALSE@
98
+AMDEP_TRUE = @AMDEP_TRUE@
99
+AMTAR = @AMTAR@
100
+AR = @AR@
101
+AUTOCONF = @AUTOCONF@
102
+AUTOHEADER = @AUTOHEADER@
103
+AUTOMAKE = @AUTOMAKE@
104
+AWK = @AWK@
105
+BUILD_CLAMD_FALSE = @BUILD_CLAMD_FALSE@
106
+BUILD_CLAMD_TRUE = @BUILD_CLAMD_TRUE@
107
+CC = @CC@
108
+CCDEPMODE = @CCDEPMODE@
109
+CFGDIR = @CFGDIR@
110
+CFLAGS = @CFLAGS@
111
+CLAMAVGROUP = @CLAMAVGROUP@
112
+CLAMAVUSER = @CLAMAVUSER@
113
+CLAMAV_MILTER_LIBS = @CLAMAV_MILTER_LIBS@
114
+CLAMD_LIBS = @CLAMD_LIBS@
115
+CPP = @CPP@
116
+CPPFLAGS = @CPPFLAGS@
117
+CXX = @CXX@
118
+CXXCPP = @CXXCPP@
119
+CXXDEPMODE = @CXXDEPMODE@
120
+CXXFLAGS = @CXXFLAGS@
121
+CYGPATH_W = @CYGPATH_W@
122
+DBDIR = @DBDIR@
123
+DEFS = @DEFS@
124
+DEPDIR = @DEPDIR@
125
+ECHO = @ECHO@
126
+ECHO_C = @ECHO_C@
127
+ECHO_N = @ECHO_N@
128
+ECHO_T = @ECHO_T@
129
+EGREP = @EGREP@
130
+EXEEXT = @EXEEXT@
131
+F77 = @F77@
132
+FFLAGS = @FFLAGS@
133
+FRESHCLAM_LIBS = @FRESHCLAM_LIBS@
134
+GETENT = @GETENT@
135
+GREP = @GREP@
136
+HAVE_MILTER_FALSE = @HAVE_MILTER_FALSE@
137
+HAVE_MILTER_TRUE = @HAVE_MILTER_TRUE@
138
+INSTALL_DATA = @INSTALL_DATA@
139
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
140
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
141
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
142
+LDFLAGS = @LDFLAGS@
143
+LIBCLAMAV_LIBS = @LIBCLAMAV_LIBS@
144
+LIBCLAMAV_VERSION = @LIBCLAMAV_VERSION@
145
+LIBOBJS = @LIBOBJS@
146
+LIBS = @LIBS@
147
+LIBTOOL = @LIBTOOL@
148
+LN_S = @LN_S@
149
+LTLIBOBJS = @LTLIBOBJS@
150
+MAINT = @MAINT@
151
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
152
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
153
+MAKEINFO = @MAKEINFO@
154
+OBJEXT = @OBJEXT@
155
+PACKAGE = @PACKAGE@
156
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
157
+PACKAGE_NAME = @PACKAGE_NAME@
158
+PACKAGE_STRING = @PACKAGE_STRING@
159
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
160
+PACKAGE_VERSION = @PACKAGE_VERSION@
161
+PATH_SEPARATOR = @PATH_SEPARATOR@
162
+RANLIB = @RANLIB@
163
+SED = @SED@
164
+SET_MAKE = @SET_MAKE@
165
+SHELL = @SHELL@
166
+STRIP = @STRIP@
167
+THREAD_LIBS = @THREAD_LIBS@
168
+TH_SAFE = @TH_SAFE@
169
+VERSION = @VERSION@
170
+ac_ct_CC = @ac_ct_CC@
171
+ac_ct_CXX = @ac_ct_CXX@
172
+ac_ct_F77 = @ac_ct_F77@
173
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
174
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
175
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
176
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
177
+am__include = @am__include@
178
+am__leading_dot = @am__leading_dot@
179
+am__quote = @am__quote@
180
+am__tar = @am__tar@
181
+am__untar = @am__untar@
182
+bindir = @bindir@
183
+build = @build@
184
+build_alias = @build_alias@
185
+build_cpu = @build_cpu@
186
+build_os = @build_os@
187
+build_vendor = @build_vendor@
188
+datadir = @datadir@
189
+datarootdir = @datarootdir@
190
+docdir = @docdir@
191
+dvidir = @dvidir@
192
+exec_prefix = @exec_prefix@
193
+host = @host@
194
+host_alias = @host_alias@
195
+host_cpu = @host_cpu@
196
+host_os = @host_os@
197
+host_vendor = @host_vendor@
198
+htmldir = @htmldir@
199
+includedir = @includedir@
200
+infodir = @infodir@
201
+install_sh = @install_sh@
202
+libdir = @libdir@
203
+libexecdir = @libexecdir@
204
+localedir = @localedir@
205
+localstatedir = @localstatedir@
206
+mandir = @mandir@
207
+mkdir_p = @mkdir_p@
208
+oldincludedir = @oldincludedir@
209
+pdfdir = @pdfdir@
210
+prefix = @prefix@
211
+program_transform_name = @program_transform_name@
212
+psdir = @psdir@
213
+sbindir = @sbindir@
214
+sendmailprog = @sendmailprog@
215
+sharedstatedir = @sharedstatedir@
216
+sysconfdir = @sysconfdir@
217
+target = @target@
218
+target_alias = @target_alias@
219
+target_cpu = @target_cpu@
220
+target_os = @target_os@
221
+target_vendor = @target_vendor@
222
+AM_CFLAGS = -fPIC -DPIC
223
+lib_LTLIBRARIES = liblzma.la
224
+liblzma_la_SOURCES = LzmaStateDecode.c
225
+liblzma_la_LDFLAGS = -static
226
+all: all-am
227
+
228
+.SUFFIXES:
229
+.SUFFIXES: .c .lo .o .obj
230
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
231
+	@for dep in $?; do \
232
+	  case '$(am__configure_deps)' in \
233
+	    *$$dep*) \
234
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
235
+		&& exit 0; \
236
+	      exit 1;; \
237
+	  esac; \
238
+	done; \
239
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  libclamav/lzma/Makefile'; \
240
+	cd $(top_srcdir) && \
241
+	  $(AUTOMAKE) --gnu  libclamav/lzma/Makefile
242
+.PRECIOUS: Makefile
243
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
244
+	@case '$?' in \
245
+	  *config.status*) \
246
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
247
+	  *) \
248
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
249
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
250
+	esac;
251
+
252
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
253
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
254
+
255
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
256
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
257
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
258
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
259
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
260
+	@$(NORMAL_INSTALL)
261
+	test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
262
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
263
+	  if test -f $$p; then \
264
+	    f=$(am__strip_dir) \
265
+	    echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
266
+	    $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
267
+	  else :; fi; \
268
+	done
269
+
270
+uninstall-libLTLIBRARIES:
271
+	@$(NORMAL_UNINSTALL)
272
+	@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
273
+	  p=$(am__strip_dir) \
274
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
275
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
276
+	done
277
+
278
+clean-libLTLIBRARIES:
279
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
280
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
281
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
282
+	  test "$$dir" != "$$p" || dir=.; \
283
+	  echo "rm -f \"$${dir}/so_locations\""; \
284
+	  rm -f "$${dir}/so_locations"; \
285
+	done
286
+liblzma.la: $(liblzma_la_OBJECTS) $(liblzma_la_DEPENDENCIES) 
287
+	$(LINK) -rpath $(libdir) $(liblzma_la_LDFLAGS) $(liblzma_la_OBJECTS) $(liblzma_la_LIBADD) $(LIBS)
288
+
289
+mostlyclean-compile:
290
+	-rm -f *.$(OBJEXT)
291
+
292
+distclean-compile:
293
+	-rm -f *.tab.c
294
+
295
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LzmaStateDecode.Plo@am__quote@
296
+
297
+.c.o:
298
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
299
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
300
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
301
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
302
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
303
+
304
+.c.obj:
305
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
306
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
307
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
308
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
309
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
310
+
311
+.c.lo:
312
+@am__fastdepCC_TRUE@	if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
313
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
314
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
315
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
316
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
317
+
318
+mostlyclean-libtool:
319
+	-rm -f *.lo
320
+
321
+clean-libtool:
322
+	-rm -rf .libs _libs
323
+
324
+distclean-libtool:
325
+	-rm -f libtool
326
+uninstall-info-am:
327
+
328
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
329
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
330
+	unique=`for i in $$list; do \
331
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
332
+	  done | \
333
+	  $(AWK) '    { files[$$0] = 1; } \
334
+	       END { for (i in files) print i; }'`; \
335
+	mkid -fID $$unique
336
+tags: TAGS
337
+
338
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
339
+		$(TAGS_FILES) $(LISP)
340
+	tags=; \
341
+	here=`pwd`; \
342
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
343
+	unique=`for i in $$list; do \
344
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
345
+	  done | \
346
+	  $(AWK) '    { files[$$0] = 1; } \
347
+	       END { for (i in files) print i; }'`; \
348
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
349
+	  test -n "$$unique" || unique=$$empty_fix; \
350
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
351
+	    $$tags $$unique; \
352
+	fi
353
+ctags: CTAGS
354
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
355
+		$(TAGS_FILES) $(LISP)
356
+	tags=; \
357
+	here=`pwd`; \
358
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
359
+	unique=`for i in $$list; do \
360
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
361
+	  done | \
362
+	  $(AWK) '    { files[$$0] = 1; } \
363
+	       END { for (i in files) print i; }'`; \
364
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
365
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
366
+	     $$tags $$unique
367
+
368
+GTAGS:
369
+	here=`$(am__cd) $(top_builddir) && pwd` \
370
+	  && cd $(top_srcdir) \
371
+	  && gtags -i $(GTAGS_ARGS) $$here
372
+
373
+distclean-tags:
374
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
375
+
376
+distdir: $(DISTFILES)
377
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
378
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
379
+	list='$(DISTFILES)'; for file in $$list; do \
380
+	  case $$file in \
381
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
382
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
383
+	  esac; \
384
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
385
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
386
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
387
+	    dir="/$$dir"; \
388
+	    $(mkdir_p) "$(distdir)$$dir"; \
389
+	  else \
390
+	    dir=''; \
391
+	  fi; \
392
+	  if test -d $$d/$$file; then \
393
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
394
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
395
+	    fi; \
396
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
397
+	  else \
398
+	    test -f $(distdir)/$$file \
399
+	    || cp -p $$d/$$file $(distdir)/$$file \
400
+	    || exit 1; \
401
+	  fi; \
402
+	done
403
+check-am: all-am
404
+check: check-am
405
+all-am: Makefile $(LTLIBRARIES)
406
+installdirs:
407
+	for dir in "$(DESTDIR)$(libdir)"; do \
408
+	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
409
+	done
410
+install: install-am
411
+install-exec: install-exec-am
412
+install-data: install-data-am
413
+uninstall: uninstall-am
414
+
415
+install-am: all-am
416
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
417
+
418
+installcheck: installcheck-am
419
+install-strip:
420
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
421
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
422
+	  `test -z '$(STRIP)' || \
423
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
424
+mostlyclean-generic:
425
+
426
+clean-generic:
427
+
428
+distclean-generic:
429
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
430
+
431
+maintainer-clean-generic:
432
+	@echo "This command is intended for maintainers to use"
433
+	@echo "it deletes files that may require special tools to rebuild."
434
+clean: clean-am
435
+
436
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
437
+	mostlyclean-am
438
+
439
+distclean: distclean-am
440
+	-rm -rf ./$(DEPDIR)
441
+	-rm -f Makefile
442
+distclean-am: clean-am distclean-compile distclean-generic \
443
+	distclean-libtool distclean-tags
444
+
445
+dvi: dvi-am
446
+
447
+dvi-am:
448
+
449
+html: html-am
450
+
451
+info: info-am
452
+
453
+info-am:
454
+
455
+install-data-am:
456
+
457
+install-exec-am: install-libLTLIBRARIES
458
+
459
+install-info: install-info-am
460
+
461
+install-man:
462
+
463
+installcheck-am:
464
+
465
+maintainer-clean: maintainer-clean-am
466
+	-rm -rf ./$(DEPDIR)
467
+	-rm -f Makefile
468
+maintainer-clean-am: distclean-am maintainer-clean-generic
469
+
470
+mostlyclean: mostlyclean-am
471
+
472
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
473
+	mostlyclean-libtool
474
+
475
+pdf: pdf-am
476
+
477
+pdf-am:
478
+
479
+ps: ps-am
480
+
481
+ps-am:
482
+
483
+uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
484
+
485
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
486
+	clean-libLTLIBRARIES clean-libtool ctags distclean \
487
+	distclean-compile distclean-generic distclean-libtool \
488
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
489
+	install install-am install-data install-data-am install-exec \
490
+	install-exec-am install-info install-info-am \
491
+	install-libLTLIBRARIES install-man install-strip installcheck \
492
+	installcheck-am installdirs maintainer-clean \
493
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
494
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
495
+	tags uninstall uninstall-am uninstall-info-am \
496
+	uninstall-libLTLIBRARIES
497
+
498
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
499
+# Otherwise a system limit (for SysV at least) may be exceeded.
500
+.NOEXPORT:
0 501
new file mode 100644
... ...
@@ -0,0 +1,630 @@
0
+LZMA SDK 4.40
1
+-------------
2
+
3
+LZMA SDK   Copyright (C) 1999-2006 Igor Pavlov
4
+
5
+LZMA SDK provides the documentation, samples, header files, libraries, 
6
+and tools you need to develop applications that use LZMA compression.
7
+
8
+LZMA is default and general compression method of 7z format
9
+in 7-Zip compression program (www.7-zip.org). LZMA provides high 
10
+compression ratio and very fast decompression.
11
+
12
+LZMA is an improved version of famous LZ77 compression algorithm. 
13
+It was improved in way of maximum increasing of compression ratio,
14
+keeping high decompression speed and low memory requirements for 
15
+decompressing.
16
+
17
+
18
+
19
+LICENSE
20
+-------
21
+
22
+LZMA SDK is available under any of the following licenses:
23
+
24
+1) GNU Lesser General Public License (GNU LGPL)
25
+2) Common Public License (CPL)
26
+3) Simplified license for unmodified code (read SPECIAL EXCEPTION) 
27
+4) Proprietary license 
28
+
29
+It means that you can select one of these four options and follow rules of that license.
30
+
31
+
32
+1,2) GNU LGPL and CPL licenses are pretty similar and both these
33
+licenses are classified as 
34
+ - "Free software licenses" at http://www.gnu.org/ 
35
+ - "OSI-approved" at http://www.opensource.org/
36
+
37
+
38
+3) SPECIAL EXCEPTION
39
+
40
+Igor Pavlov, as the author of this code, expressly permits you 
41
+to statically or dynamically link your code (or bind by name) 
42
+to the files from LZMA SDK without subjecting your linked 
43
+code to the terms of the CPL or GNU LGPL. 
44
+Any modifications or additions to files from LZMA SDK, however, 
45
+are subject to the GNU LGPL or CPL terms.
46
+
47
+SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code, 
48
+while you keep LZMA SDK code unmodified.
49
+
50
+
51
+SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits 
52
+you to use this code under the same terms and conditions contained in the License 
53
+Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov.
54
+
55
+SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version 
56
+of LZMA SDK as update for previous versions.
57
+
58
+
59
+SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits 
60
+you to use code of the following files: 
61
+BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp, 
62
+LzmaAlone.cs, LzmaAlone.java
63
+as public domain code. 
64
+
65
+
66
+4) Proprietary license
67
+
68
+LZMA SDK also can be available under a proprietary license which 
69
+can include:
70
+
71
+1) Right to modify code without subjecting modified code to the 
72
+terms of the CPL or GNU LGPL
73
+2) Technical support for code
74
+
75
+To request such proprietary license or any additional consultations,
76
+send email message from that page:
77
+http://www.7-zip.org/support.html
78
+
79
+
80
+You should have received a copy of the GNU Lesser General Public
81
+License along with this library; if not, write to the Free Software
82
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
83
+
84
+You should have received a copy of the Common Public License
85
+along with this library.
86
+
87
+
88
+LZMA SDK Contents
89
+-----------------
90
+
91
+LZMA SDK includes:
92
+
93
+  - C++ source code of LZMA compressing and decompressing
94
+  - ANSI-C compatible source code for LZMA decompressing
95
+  - C# source code for LZMA compressing and decompressing
96
+  - Java source code for LZMA compressing and decompressing
97
+  - Compiled file->file LZMA compressing/decompressing program for Windows system
98
+
99
+ANSI-C LZMA decompression code was ported from original C++ sources to C.
100
+Also it was simplified and optimized for code size. 
101
+But it is fully compatible with LZMA from 7-Zip.
102
+
103
+
104
+UNIX/Linux version 
105
+------------------
106
+To compile C++ version of file->file LZMA, go to directory
107
+C/7zip/Compress/LZMA_Alone 
108
+and type "make" or "make clean all" to recompile all.
109
+
110
+In some UNIX/Linux versions you must compile LZMA with static libraries.
111
+To compile with static libraries, change string in makefile
112
+LIB = -lm
113
+to string  
114
+LIB = -lm -static
115
+
116
+
117
+Files
118
+---------------------
119
+C        - C / CPP source code
120
+CS       - C# source code
121
+Java     - Java source code
122
+lzma.txt - LZMA SDK description (this file)
123
+7zFormat.txt - 7z Format description
124
+7zC.txt  - 7z ANSI-C Decoder description (this file)
125
+methods.txt  - Compression method IDs for .7z
126
+LGPL.txt - GNU Lesser General Public License
127
+CPL.html - Common Public License
128
+lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
129
+history.txt - history of the LZMA SDK
130
+
131
+
132
+Source code structure
133
+---------------------
134
+
135
+C  - C / CPP files
136
+  Common  - common files for C++ projects
137
+  Windows - common files for Windows related code
138
+  7zip    - files related to 7-Zip Project
139
+    Common   - common files for 7-Zip
140
+    Compress - files related to compression/decompression
141
+      LZ     - files related to LZ (Lempel-Ziv) compression algorithm
142
+        BinTree    - Binary Tree Match Finder for LZ algorithm
143
+        HashChain  - Hash Chain Match Finder for LZ algorithm
144
+        Patricia   - Patricia Match Finder for LZ algorithm
145
+      RangeCoder   - Range Coder (special code of compression/decompression)
146
+      LZMA         - LZMA compression/decompression on C++
147
+      LZMA_Alone   - file->file LZMA compression/decompression
148
+      LZMA_C       - ANSI-C compatible LZMA decompressor
149
+        LzmaDecode.h  - interface for LZMA decoding on ANSI-C
150
+        LzmaDecode.c      - LZMA decoding on ANSI-C (new fastest version)
151
+        LzmaDecodeSize.c  - LZMA decoding on ANSI-C (old size-optimized version)
152
+        LzmaTest.c        - test application that decodes LZMA encoded file
153
+        LzmaTypes.h       - basic types for LZMA Decoder
154
+        LzmaStateDecode.h - interface for LZMA decoding (State version)
155
+        LzmaStateDecode.c - LZMA decoding on ANSI-C (State version)
156
+        LzmaStateTest.c   - test application (State version)
157
+      Branch       - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
158
+    Archive - files related to archiving
159
+      7z_C     - 7z ANSI-C Decoder
160
+
161
+CS - C# files
162
+  7zip
163
+    Common   - some common files for 7-Zip
164
+    Compress - files related to compression/decompression
165
+      LZ     - files related to LZ (Lempel-Ziv) compression algorithm
166
+      LZMA         - LZMA compression/decompression
167
+      LzmaAlone    - file->file LZMA compression/decompression
168
+      RangeCoder   - Range Coder (special code of compression/decompression)
169
+
170
+Java  - Java files
171
+  SevenZip
172
+    Compression    - files related to compression/decompression
173
+      LZ           - files related to LZ (Lempel-Ziv) compression algorithm
174
+      LZMA         - LZMA compression/decompression
175
+      RangeCoder   - Range Coder (special code of compression/decompression)
176
+
177
+C/C++ source code of LZMA SDK is part of 7-Zip project.
178
+
179
+You can find ANSI-C LZMA decompressing code at folder 
180
+  C/7zip/Compress/LZMA_C
181
+7-Zip doesn't use that ANSI-C LZMA code and that code was developed 
182
+specially for this SDK. And files from LZMA_C do not need files from 
183
+other directories of SDK for compiling.
184
+
185
+7-Zip source code can be downloaded from 7-Zip's SourceForge page:
186
+
187
+  http://sourceforge.net/projects/sevenzip/
188
+
189
+
190
+LZMA features
191
+-------------
192
+  - Variable dictionary size (up to 1 GB)
193
+  - Estimated compressing speed: about 1 MB/s on 1 GHz CPU
194
+  - Estimated decompressing speed: 
195
+      - 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon
196
+      - 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC
197
+  - Small memory requirements for decompressing (8-32 KB + DictionarySize)
198
+  - Small code size for decompressing: 2-8 KB (depending from 
199
+    speed optimizations) 
200
+
201
+LZMA decoder uses only integer operations and can be 
202
+implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
203
+
204
+Some critical operations that affect to speed of LZMA decompression:
205
+  1) 32*16 bit integer multiply
206
+  2) Misspredicted branches (penalty mostly depends from pipeline length)
207
+  3) 32-bit shift and arithmetic operations
208
+
209
+Speed of LZMA decompressing mostly depends from CPU speed.
210
+Memory speed has no big meaning. But if your CPU has small data cache, 
211
+overall weight of memory speed will slightly increase.
212
+
213
+
214
+How To Use
215
+----------
216
+
217
+Using LZMA encoder/decoder executable
218
+--------------------------------------
219
+
220
+Usage:  LZMA <e|d> inputFile outputFile [<switches>...]
221
+
222
+  e: encode file
223
+
224
+  d: decode file
225
+
226
+  b: Benchmark. There are two tests: compressing and decompressing 
227
+     with LZMA method. Benchmark shows rating in MIPS (million 
228
+     instructions per second). Rating value is calculated from 
229
+     measured speed and it is normalized with AMD Athlon 64 X2 CPU
230
+     results. Also Benchmark checks possible hardware errors (RAM 
231
+     errors in most cases). Benchmark uses these settings:
232
+     (-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you 
233
+     can change number of iterations. Example for 30 iterations:
234
+	LZMA b 30
235
+     Default number of iterations is 10.
236
+
237
+<Switches>
238
+  
239
+
240
+  -a{N}:  set compression mode 0 = fast, 1 = normal
241
+          default: 1 (normal)
242
+
243
+  d{N}:   Sets Dictionary size - [0, 30], default: 23 (8MB)
244
+          The maximum value for dictionary size is 1 GB = 2^30 bytes.
245
+          Dictionary size is calculated as DictionarySize = 2^N bytes. 
246
+          For decompressing file compressed by LZMA method with dictionary 
247
+          size D = 2^N you need about D bytes of memory (RAM).
248
+
249
+  -fb{N}: set number of fast bytes - [5, 273], default: 128
250
+          Usually big number gives a little bit better compression ratio 
251
+          and slower compression process.
252
+
253
+  -lc{N}: set number of literal context bits - [0, 8], default: 3
254
+          Sometimes lc=4 gives gain for big files.
255
+
256
+  -lp{N}: set number of literal pos bits - [0, 4], default: 0
257
+          lp switch is intended for periodical data when period is 
258
+          equal 2^N. For example, for 32-bit (4 bytes) 
259
+          periodical data you can use lp=2. Often it's better to set lc0, 
260
+          if you change lp switch.
261
+
262
+  -pb{N}: set number of pos bits - [0, 4], default: 2
263
+          pb switch is intended for periodical data 
264
+          when period is equal 2^N.
265
+
266
+  -mf{MF_ID}: set Match Finder. Default: bt4. 
267
+              Algorithms from hc* group doesn't provide good compression 
268
+              ratio, but they often works pretty fast in combination with 
269
+              fast mode (-a0).
270
+
271
+              Memory requirements depend from dictionary size 
272
+              (parameter "d" in table below). 
273
+
274
+               MF_ID     Memory                   Description
275
+
276
+                bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.
277
+                bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.
278
+                bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.
279
+                hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.
280
+
281
+  -eos:   write End Of Stream marker. By default LZMA doesn't write 
282
+          eos marker, since LZMA decoder knows uncompressed size 
283
+          stored in .lzma file header.
284
+
285
+  -si:    Read data from stdin (it will write End Of Stream marker).
286
+  -so:    Write data to stdout
287
+
288
+
289
+Examples:
290
+
291
+1) LZMA e file.bin file.lzma -d16 -lc0 
292
+
293
+compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)  
294
+and 0 literal context bits. -lc0 allows to reduce memory requirements 
295
+for decompression.
296
+
297
+
298
+2) LZMA e file.bin file.lzma -lc0 -lp2
299
+
300
+compresses file.bin to file.lzma with settings suitable 
301
+for 32-bit periodical data (for example, ARM or MIPS code).
302
+
303
+3) LZMA d file.lzma file.bin
304
+
305
+decompresses file.lzma to file.bin.
306
+
307
+
308
+Compression ratio hints
309
+-----------------------
310
+
311
+Recommendations
312
+---------------
313
+
314
+To increase compression ratio for LZMA compressing it's desirable 
315
+to have aligned data (if it's possible) and also it's desirable to locate
316
+data in such order, where code is grouped in one place and data is 
317
+grouped in other place (it's better than such mixing: code, data, code,
318
+data, ...).
319
+
320
+
321
+Using Filters
322
+-------------
323
+You can increase compression ratio for some data types, using
324
+special filters before compressing. For example, it's possible to 
325
+increase compression ratio on 5-10% for code for those CPU ISAs: 
326
+x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.
327
+
328
+You can find C/C++ source code of such filters in folder "7zip/Compress/Branch"
329
+
330
+You can check compression ratio gain of these filters with such 
331
+7-Zip commands (example for ARM code):
332
+No filter:
333
+  7z a a1.7z a.bin -m0=lzma
334
+
335
+With filter for little-endian ARM code:
336
+  7z a a2.7z a.bin -m0=bc_arm -m1=lzma        
337
+
338
+With filter for big-endian ARM code (using additional Swap4 filter):
339
+  7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma
340
+
341
+It works in such manner:
342
+Compressing    = Filter_encoding + LZMA_encoding
343
+Decompressing  = LZMA_decoding + Filter_decoding
344
+
345
+Compressing and decompressing speed of such filters is very high,
346
+so it will not increase decompressing time too much.
347
+Moreover, it reduces decompression time for LZMA_decoding, 
348
+since compression ratio with filtering is higher.
349
+
350
+These filters convert CALL (calling procedure) instructions 
351
+from relative offsets to absolute addresses, so such data becomes more 
352
+compressible. Source code of these CALL filters is pretty simple
353
+(about 20 lines of C++), so you can convert it from C++ version yourself.
354
+
355
+For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
356
+
357
+
358
+LZMA compressed file format
359
+---------------------------
360
+Offset Size Description
361
+  0     1   Special LZMA properties for compressed data
362
+  1     4   Dictionary size (little endian)
363
+  5     8   Uncompressed size (little endian). -1 means unknown size
364
+ 13         Compressed data
365
+
366
+
367
+ANSI-C LZMA Decoder
368
+~~~~~~~~~~~~~~~~~~~
369
+
370
+To compile ANSI-C LZMA Decoder you can use one of the following files sets:
371
+1) LzmaDecode.h + LzmaDecode.c + LzmaTest.c  (fastest version)
372
+2) LzmaDecode.h + LzmaDecodeSize.c + LzmaTest.c  (old size-optimized version)
373
+3) LzmaStateDecode.h + LzmaStateDecode.c + LzmaStateTest.c  (zlib-like interface)
374
+
375
+
376
+Memory requirements for LZMA decoding
377
+-------------------------------------
378
+
379
+LZMA decoder doesn't allocate memory itself, so you must 
380
+allocate memory and send it to LZMA.
381
+
382
+Stack usage of LZMA decoding function for local variables is not 
383
+larger than 200 bytes.
384
+
385
+How To decompress data
386
+----------------------
387
+
388
+LZMA Decoder (ANSI-C version) now supports 5 interfaces:
389
+1) Single-call Decompressing
390
+2) Single-call Decompressing with input stream callback
391
+3) Multi-call Decompressing with output buffer
392
+4) Multi-call Decompressing with input callback and output buffer
393
+5) Multi-call State Decompressing (zlib-like interface)
394
+
395
+Variant-5 is similar to Variant-4, but Variant-5 doesn't use callback functions.
396
+
397
+Decompressing steps
398
+-------------------
399
+
400
+1) read LZMA properties (5 bytes):
401
+   unsigned char properties[LZMA_PROPERTIES_SIZE];
402
+
403
+2) read uncompressed size (8 bytes, little-endian)
404
+
405
+3) Decode properties:
406
+
407
+  CLzmaDecoderState state;  /* it's 24-140 bytes structure, if int is 32-bit */
408
+
409
+  if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
410
+    return PrintError(rs, "Incorrect stream properties");
411
+
412
+4) Allocate memory block for internal Structures:
413
+
414
+  state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
415
+  if (state.Probs == 0)
416
+    return PrintError(rs, kCantAllocateMessage);
417
+
418
+  LZMA decoder uses array of CProb variables as internal structure.
419
+  By default, CProb is unsigned_short. But you can define _LZMA_PROB32 to make 
420
+  it unsigned_int. It can increase speed on some 32-bit CPUs, but memory 
421
+  usage will be doubled in that case.
422
+
423
+
424
+5) Main Decompressing
425
+
426
+You must use one of the following interfaces:
427
+
428
+5.1 Single-call Decompressing
429
+-----------------------------
430
+When to use: RAM->RAM decompressing
431
+Compile files: LzmaDecode.h, LzmaDecode.c
432
+Compile defines: no defines
433
+Memory Requirements:
434
+  - Input buffer: compressed size
435
+  - Output buffer: uncompressed size
436
+  - LZMA Internal Structures (~16 KB for default settings) 
437
+
438
+Interface:
439
+  int res = LzmaDecode(&state, 
440
+      inStream, compressedSize, &inProcessed,
441
+      outStream, outSize, &outProcessed);
442
+
443
+
444
+5.2 Single-call Decompressing with input stream callback
445
+--------------------------------------------------------
446
+When to use: File->RAM or Flash->RAM decompressing.
447
+Compile files: LzmaDecode.h, LzmaDecode.c
448
+Compile defines: _LZMA_IN_CB
449
+Memory Requirements:
450
+  - Buffer for input stream: any size (for example, 16 KB)
451
+  - Output buffer: uncompressed size
452
+  - LZMA Internal Structures (~16 KB for default settings) 
453
+
454
+Interface:
455
+  typedef struct _CBuffer
456
+  {
457
+    ILzmaInCallback InCallback;
458
+    FILE *File;
459
+    unsigned char Buffer[kInBufferSize];
460
+  } CBuffer;
461
+
462
+  int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
463
+  {
464
+    CBuffer *bo = (CBuffer *)object;
465
+    *buffer = bo->Buffer;
466
+    *size = MyReadFile(bo->File, bo->Buffer, kInBufferSize);
467
+    return LZMA_RESULT_OK;
468
+  }
469
+
470
+  CBuffer g_InBuffer;
471
+
472
+  g_InBuffer.File = inFile;
473
+  g_InBuffer.InCallback.Read = LzmaReadCompressed;
474
+  int res = LzmaDecode(&state, 
475
+      &g_InBuffer.InCallback,
476
+      outStream, outSize, &outProcessed);
477
+
478
+
479
+5.3 Multi-call decompressing with output buffer
480
+-----------------------------------------------
481
+When to use: RAM->File decompressing 
482
+Compile files: LzmaDecode.h, LzmaDecode.c
483
+Compile defines: _LZMA_OUT_READ
484
+Memory Requirements:
485
+ - Input buffer: compressed size
486
+ - Buffer for output stream: any size (for example, 16 KB)
487
+ - LZMA Internal Structures (~16 KB for default settings) 
488
+ - LZMA dictionary (dictionary size is encoded in stream properties)
489
+ 
490
+Interface:
491
+
492
+  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
493
+
494
+  LzmaDecoderInit(&state);
495
+  do
496
+  {
497
+    LzmaDecode(&state,
498
+      inBuffer, inAvail, &inProcessed,
499
+      g_OutBuffer, outAvail, &outProcessed);
500
+    inAvail -= inProcessed;
501
+    inBuffer += inProcessed;
502
+  }
503
+  while you need more bytes
504
+
505
+  see LzmaTest.c for more details.
506
+
507
+
508
+5.4 Multi-call decompressing with input callback and output buffer
509
+------------------------------------------------------------------
510
+When to use: File->File decompressing 
511
+Compile files: LzmaDecode.h, LzmaDecode.c
512
+Compile defines: _LZMA_IN_CB, _LZMA_OUT_READ
513
+Memory Requirements:
514
+ - Buffer for input stream: any size (for example, 16 KB)
515
+ - Buffer for output stream: any size (for example, 16 KB)
516
+ - LZMA Internal Structures (~16 KB for default settings) 
517
+ - LZMA dictionary (dictionary size is encoded in stream properties)
518
+ 
519
+Interface:
520
+
521
+  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
522
+ 
523
+  LzmaDecoderInit(&state);
524
+  do
525
+  {
526
+    LzmaDecode(&state,
527
+      &bo.InCallback,
528
+      g_OutBuffer, outAvail, &outProcessed);
529
+  }
530
+  while you need more bytes
531
+
532
+  see LzmaTest.c for more details:
533
+
534
+
535
+5.5 Multi-call State Decompressing (zlib-like interface)
536
+------------------------------------------------------------------
537
+When to use: file->file decompressing 
538
+Compile files: LzmaStateDecode.h, LzmaStateDecode.c
539
+Compile defines:
540
+Memory Requirements:
541
+ - Buffer for input stream: any size (for example, 16 KB)
542
+ - Buffer for output stream: any size (for example, 16 KB)
543
+ - LZMA Internal Structures (~16 KB for default settings) 
544
+ - LZMA dictionary (dictionary size is encoded in stream properties)
545
+ 
546
+Interface:
547
+
548
+  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
549
+
550
+  
551
+  LzmaDecoderInit(&state);
552
+  do
553
+  {
554
+    res = LzmaDecode(&state,
555
+      inBuffer, inAvail, &inProcessed,
556
+      g_OutBuffer, outAvail, &outProcessed,
557
+      finishDecoding);
558
+    inAvail -= inProcessed;
559
+    inBuffer += inProcessed;
560
+  }
561
+  while you need more bytes
562
+
563
+  see LzmaStateTest.c for more details:
564
+
565
+
566
+6) Free all allocated blocks
567
+
568
+
569
+Note
570
+----
571
+LzmaDecodeSize.c is size-optimized version of LzmaDecode.c.
572
+But compiled code of LzmaDecodeSize.c can be larger than 
573
+compiled code of LzmaDecode.c. So it's better to use 
574
+LzmaDecode.c in most cases.
575
+
576
+
577
+EXIT codes
578
+-----------
579
+
580
+LZMA decoder can return one of the following codes:
581
+
582
+#define LZMA_RESULT_OK 0
583
+#define LZMA_RESULT_DATA_ERROR 1
584
+
585
+If you use callback function for input data and you return some 
586
+error code, LZMA Decoder also returns that code.
587
+
588
+
589
+
590
+LZMA Defines
591
+------------
592
+
593
+_LZMA_IN_CB    - Use callback for input data
594
+
595
+_LZMA_OUT_READ - Use read function for output data
596
+
597
+_LZMA_LOC_OPT  - Enable local speed optimizations inside code.
598
+                 _LZMA_LOC_OPT is only for LzmaDecodeSize.c (size-optimized version).
599
+                 _LZMA_LOC_OPT doesn't affect LzmaDecode.c (speed-optimized version)
600
+                 and LzmaStateDecode.c
601
+
602
+_LZMA_PROB32   - It can increase speed on some 32-bit CPUs, 
603
+                 but memory usage will be doubled in that case
604
+
605
+_LZMA_UINT32_IS_ULONG  - Define it if int is 16-bit on your compiler
606
+                         and long is 32-bit.
607
+
608
+_LZMA_SYSTEM_SIZE_T  - Define it if you want to use system's size_t.
609
+                       You can use it to enable 64-bit sizes supporting
610
+
611
+
612
+
613
+C++ LZMA Encoder/Decoder 
614
+~~~~~~~~~~~~~~~~~~~~~~~~
615
+C++ LZMA code use COM-like interfaces. So if you want to use it, 
616
+you can study basics of COM/OLE.
617
+
618
+By default, LZMA Encoder contains all Match Finders.
619
+But for compressing it's enough to have just one of them.
620
+So for reducing size of compressing code you can define:
621
+  #define COMPRESS_MF_BT
622
+  #define COMPRESS_MF_BT4
623
+and it will use only bt4 match finder.
624
+
625
+
626
+---
627
+
628
+http://www.7-zip.org
629
+http://www.7-zip.org/support.html
0 630
new file mode 100644
... ...
@@ -0,0 +1,80 @@
0
+/*
1
+ *  Copyright (C) 2007 Sourcefire Inc.
2
+ *  Author: aCaB <acab@clamav.net>
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License version 2 as
6
+ *  published by the Free Software Foundation.
7
+ *
8
+ *  This program is distributed in the hope that it will be useful,
9
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
+ *  GNU General Public License for more details.
12
+ *
13
+ *  You should have received a copy of the GNU General Public License
14
+ *  along with this program; if not, write to the Free Software
15
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ *  MA 02110-1301, USA.
17
+ */
18
+
19
+/* a cleaner state interface to LZMA */
20
+
21
+
22
+#include "lzma_iface.h"
23
+#include "cltypes.h"
24
+#include "others.h"
25
+
26
+int cli_LzmaInit(CLI_LZMA *L, uint64_t size_override) {
27
+  L->initted = 0;
28
+  if(size_override) L->usize=size_override;
29
+
30
+  if (!L->next_in || L->avail_in < LZMA_PROPERTIES_SIZE + 8) return LZMA_RESULT_OK;
31
+  if (LzmaDecodeProperties(&L->state.Properties, L->next_in, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
32
+    return LZMA_RESULT_DATA_ERROR;
33
+
34
+  L->next_in += LZMA_PROPERTIES_SIZE;
35
+  L->avail_in -= LZMA_PROPERTIES_SIZE;
36
+
37
+  if (!L->usize) {
38
+    L->usize=(uint64_t)cli_readint32(L->next_in) + ((uint64_t)cli_readint32(L->next_in+4)<<32);
39
+    L->next_in += 8;
40
+    L->avail_in -= 8;
41
+  }
42
+    
43
+  if (!(L->state.Probs = (CProb *)cli_malloc(LzmaGetNumProbs(&L->state.Properties) * sizeof(CProb))))
44
+    return LZMA_RESULT_DATA_ERROR;
45
+
46
+  if (!(L->state.Dictionary = (unsigned char *)cli_malloc(L->state.Properties.DictionarySize))) {
47
+    free(L->state.Probs);
48
+    return LZMA_RESULT_DATA_ERROR;
49
+  }
50
+
51
+  L->initted = 1;
52
+
53
+  LzmaDecoderInit(&L->state);
54
+  return LZMA_RESULT_OK;
55
+}
56
+
57
+void cli_LzmaShutdown(CLI_LZMA *L) {
58
+  if(!L->initted) return;
59
+  if(L->state.Probs) free(L->state.Probs);
60
+  if(L->state.Dictionary) free(L->state.Dictionary);
61
+  return;
62
+}
63
+
64
+int cli_LzmaDecode(CLI_LZMA *L) {
65
+  int res;
66
+  SizeT processed_in, processed_out;
67
+
68
+  if (!L->initted && cli_LzmaInit(L, 0) != LZMA_RESULT_OK) 
69
+    return LZMA_RESULT_DATA_ERROR;
70
+
71
+  res = LzmaDecode(&L->state, L->next_in, L->avail_in, &processed_in, L->next_out, L->avail_out, &processed_out, (L->avail_in==0));
72
+
73
+  L->next_in += processed_in;
74
+  L->avail_in -= processed_in;
75
+  L->next_out += processed_out;
76
+  L->avail_out -= processed_out;
77
+
78
+  return res;
79
+}
0 80
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+/*
1
+ *  Copyright (C) 2007 Sourcefire Inc.
2
+ *  Author: aCaB <acab@clamav.net>
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License version 2 as
6
+ *  published by the Free Software Foundation.
7
+ *
8
+ *  This program is distributed in the hope that it will be useful,
9
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
+ *  GNU General Public License for more details.
12
+ *
13
+ *  You should have received a copy of the GNU General Public License
14
+ *  along with this program; if not, write to the Free Software
15
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ *  MA 02110-1301, USA.
17
+ */
18
+
19
+/* a cleaner state interface to LZMA */
20
+
21
+#ifndef __LZMA_IFACE_H
22
+#define __LZMA_IFACE_H
23
+
24
+#include "LzmaStateDecode.h"
25
+#include "cltypes.h"
26
+
27
+typedef struct {
28
+  CLzmaDecoderState state;
29
+  const unsigned char *next_in;
30
+  SizeT avail_in;
31
+  unsigned char *next_out;
32
+  SizeT avail_out;
33
+  int initted;
34
+  uint64_t usize;
35
+} CLI_LZMA;
36
+
37
+int cli_LzmaInit(CLI_LZMA *, uint64_t);
38
+void cli_LzmaShutdown(CLI_LZMA *);
39
+int cli_LzmaDecode(CLI_LZMA *);
40
+
41
+#define LZMA_STREAM_END 2
42
+#endif /* __LZMA_IFACE_H */
0 43
deleted file mode 100644
... ...
@@ -1,557 +0,0 @@
1
-/*
2
- * LZMADecode.c
3
- * 
4
- * This file is a part of LZMA compression module for NSIS.
5
- * 
6
- * Original LZMA SDK Copyright (C) 1999-2006 Igor Pavlov
7
- * Modifications Copyright (C) 2003-2007 Amir Szekely <kichik@netvision.net.il>
8
- * 
9
- * Licensed under the Common Public License version 1.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * 
12
- * Licence details can be found in the file COPYING.nsis.
13
- * 
14
- * This software is provided 'as-is', without any express or implied
15
- * warranty.
16
- */
17
-
18
-#include <stdlib.h>
19
-#include "LZMADecode.h"
20
-
21
-#define LEAVE { goto saveStateAndReturn; }
22
-#define NEED_BYTE(c) case c: if (!avail_in) { mode = c; LEAVE; }
23
-#define NEED_BYTE_ if (!avail_in) LEAVE;
24
-#define NEXT_BYTE (avail_in--, *next_in++)
25
-#define NEED_OUT(c) case c: if (!avail_out) { mode = c; LEAVE; }
26
-#define PUT_BYTE_(b) { *next_out = b; next_out++; avail_out--; }
27
-#define PUT_BYTE(b) { totalOut++; PUT_BYTE_(b) }
28
-#define DECODE_BIT(c, x) prob = x; last = c; goto _LZMA_C_RDBD; case c:
29
-#define DECODE_LEN(c, x) probs = x; last2 = c; goto _LZMA_C_LEND; case c:
30
-#define DECODE_BIT_TREE(c, x, y) probs = x; numLevels = y; last3 = c; goto _LZMA_C_BTD; case c:
31
-
32
-enum {
33
-  /*  0 */ LZMA_C_INIT = 0,
34
-  /*  1 */ LZMA_C_GETDICT,
35
-  /*  2 */ LZMA_C_BLOCK,
36
-  /*  3 */ LZMA_C_RDI, /* RangeDecoderInit */
37
-  /*  4 */ LZMA_C_RDBD, /* RangeDecoderBitDecode */
38
-  /*  5 */ LZMA_C_RDBD_IN, /* RangeDecoderBitDecode */
39
-  /*  6 */ LZMA_C_TYPE,
40
-  /*  7 */ LZMA_C_ISREP,
41
-  /*  8 */ LZMA_C_ISREPG0,
42
-  /*  9 */ LZMA_C_ISREP0LONG,
43
-  /* 10 */ LZMA_C_ISREPG1,
44
-  /* 11 */ LZMA_C_ISREPG2,
45
-  /* 12 */ LZMA_C_NORM,
46
-  /* 13 */ LZMA_C_LITDM1, /* LzmaLiteralDecodeMatch */
47
-  /* 14 */ LZMA_C_LITDM2, /* LzmaLiteralDecodeMatch */
48
-  /* 15 */ LZMA_C_LITD, /* LzmaLiteralDecode */
49
-  /* 16 */ LZMA_C_RDRBTD, /* RangeDecoderReverseBitTreeDecode */
50
-  /* 17 */ LZMA_C_LEND, /* LzmaLenDecode */
51
-  /* 18 */ LZMA_C_LEND1, /* LzmaLenDecode */
52
-  /* 19 */ LZMA_C_LEND2, /* LzmaLenDecode */
53
-  /* 20 */ LZMA_C_LEND_RES, /* LzmaLenDecode */
54
-  /* 21 */ LZMA_C_LEND_C1,
55
-  /* 22 */ LZMA_C_LEND_C2,
56
-  /* 23 */ LZMA_C_BTD, /* RangeDecoderBitTreeDecode */
57
-  /* 24 */ LZMA_C_BTD_LOOP,
58
-  /* 25 */ LZMA_C_BTD_C1,
59
-  /* 26 */ LZMA_C_OUTPUT_1,
60
-  /* 27 */ LZMA_C_OUTPUT_2,
61
-  /* 28 */ LZMA_C_OUTPUT_3
62
-};
63
-
64
-#define kNumTopBits 24
65
-#define kTopValue ((UInt32)1 << kNumTopBits)
66
-
67
-#define kNumBitModelTotalBits 11
68
-#define kBitModelTotal (1 << kNumBitModelTotalBits)
69
-#define kNumMoveBits 5
70
-
71
-#define RC_NORMALIZE(c) if (range < kTopValue) { NEED_BYTE(c); range <<= 8; code = (code << 8) | NEXT_BYTE; }
72
-
73
-#define RC_GET_BIT2(c, prob, mi, A0, A1) { \
74
-  UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \
75
-  if (code < bound) \
76
-    { A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \
77
-  else \
78
-    { A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \
79
-  RC_NORMALIZE(c) \
80
-}
81
-
82
-#define RC_GET_BIT(c, prob, mi) RC_GET_BIT2(c, prob, mi, ; , ;)
83
-
84
-#define kNumPosBitsMax 4
85
-#define kNumPosStatesMax (1 << kNumPosBitsMax)
86
-
87
-#define kLenNumLowBits 3
88
-#define kLenNumLowSymbols (1 << kLenNumLowBits)
89
-#define kLenNumMidBits 3
90
-#define kLenNumMidSymbols (1 << kLenNumMidBits)
91
-#define kLenNumHighBits 8
92
-#define kLenNumHighSymbols (1 << kLenNumHighBits)
93
-
94
-#define LenChoice 0
95
-#define LenChoice2 (LenChoice + 1)
96
-#define LenLow (LenChoice2 + 1)
97
-#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
98
-#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
99
-#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
100
-
101
-#define kNumStates 12
102
-
103
-#define kStartPosModelIndex 4
104
-#define kEndPosModelIndex 14
105
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
106
-
107
-#define kNumPosSlotBits 6
108
-#define kNumLenToPosStates 4
109
-
110
-#define kNumAlignBits 4
111
-#define kAlignTableSize (1 << kNumAlignBits)
112
-
113
-#define kMatchMinLen 2
114
-
115
-#define IsMatch 0
116
-#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
117
-#define IsRepG0 (IsRep + kNumStates)
118
-#define IsRepG1 (IsRepG0 + kNumStates)
119
-#define IsRepG2 (IsRepG1 + kNumStates)
120
-#define IsRep0Long (IsRepG2 + kNumStates)
121
-#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
122
-#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
123
-#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
124
-#define LenCoder (Align + kAlignTableSize)
125
-#define RepLenCoder (LenCoder + kNumLenProbs)
126
-#define Literal (RepLenCoder + kNumLenProbs)
127
-
128
-#define LZMA_BASE_SIZE 1846
129
-#define LZMA_LIT_SIZE 768
130
-
131
-#if Literal != LZMA_BASE_SIZE
132
-StopCompilingDueBUG
133
-#endif
134
-
135
-void lzmaInit(lzma_stream *s)
136
-{
137
-  /* size of lzma_stream minus the size of the two allocated buffer pointers.
138
-     we don't want to lose to pointer or else we won't be able to free them. */
139
-  size_t i = sizeof(lzma_stream) - (sizeof(unsigned char *) * 2);
140
-  while (i--)
141
-    ((lzByte *)s)[i] = 0;
142
-
143
-  s->rep0 = s->rep1 = s->rep2 = s->rep3 = 1;
144
-  s->range = (0xFFFFFFFF);
145
-}
146
-
147
-int lzmaDecode(lzma_stream *s)
148
-{
149
-  /* restore decoder state */
150
-  lzma_stream _s = *s;
151
-
152
-#define mode _s.mode
153
-#define last _s.last
154
-#define last2 _s.last2
155
-#define last3 _s.last3
156
-
157
-#define p (*(CProb **) &_s.dynamicData)
158
-#define dynamicDataSize _s.dynamicDataSize
159
-
160
-#define state _s.state
161
-#define isPreviousMatch _s.isPreviousMatch
162
-#define previousByte _s.previousByte
163
-#define rep0 _s.rep0
164
-#define rep1 _s.rep1
165
-#define rep2 _s.rep2
166
-#define rep3 _s.rep3
167
-#define lc _s.lc
168
-#define len _s.len
169
-#define totalOut _s.totalOut
170
-
171
-#define dictionary _s.dictionary
172
-#define dictionarySize _s.dictionarySize
173
-#define dictionaryPos _s.dictionaryPos
174
-
175
-#define posStateMask _s.posStateMask
176
-#define literalPosMask _s.literalPosMask
177
-
178
-#define avail_in _s.avail_in
179
-#define next_in _s.next_in
180
-#define avail_out _s.avail_out
181
-#define next_out _s.next_out
182
-
183
-#define range _s.range
184
-#define code _s.code
185
-
186
-#define probs _s.probs
187
-#define prob _s.prob
188
-
189
-#define symbol _s.temp2
190
-#define bit _s.temp3
191
-#define matchBit _s.temp1
192
-#define i _s.temp1
193
-#define result _s.temp2
194
-#define numLevels _s.temp3
195
-#define posSlot _s.temp2
196
-#define newDictionarySize (*(UInt32*) &_s.temp3)
197
-
198
-#define matchByte _s.matchByte
199
-#define mi _s.mi
200
-#define posState _s.posState
201
-
202
-  if (len == -1)
203
-    return LZMA_STREAM_END;
204
-
205
-  for (;;) switch (mode)
206
-  {
207
-  case LZMA_C_INIT:
208
-    {
209
-      lzByte firstByte;
210
-      UInt32 newDynamicDataSize;
211
-      UInt32 numProbs;
212
-      int lp;
213
-      int pb;
214
-
215
-      NEED_BYTE_;
216
-
217
-      firstByte = NEXT_BYTE;
218
-
219
-      if (firstByte > (9*5*5))
220
-        return LZMA_DATA_ERROR;
221
-
222
-      pb = firstByte / (9*5);
223
-      firstByte %= (9*5);
224
-      lp = firstByte / 9;
225
-      firstByte %= 9;
226
-      lc = firstByte;
227
-
228
-      posStateMask = (1 << (pb)) - 1;
229
-      literalPosMask = (1 << (lp)) - 1;
230
-
231
-      numProbs = Literal + (LZMA_LIT_SIZE << (lc + pb));
232
-      newDynamicDataSize = numProbs * sizeof(CProb);
233
-
234
-      if (newDynamicDataSize != dynamicDataSize)
235
-      {
236
-        if (p)
237
-          lzmafree(p);
238
-        p = lzmaalloc(newDynamicDataSize);
239
-        if (!p)
240
-          return LZMA_NOT_ENOUGH_MEM;
241
-        dynamicDataSize = newDynamicDataSize;
242
-      }
243
-
244
-      while (numProbs--)
245
-        p[numProbs] = kBitModelTotal >> 1;
246
-
247
-      for (i = 0, newDictionarySize = 0; i < 4; i++)
248
-      {
249
-        NEED_BYTE(LZMA_C_GETDICT);
250
-        newDictionarySize |= NEXT_BYTE << (i * 8);
251
-      }
252
-
253
-      if (newDictionarySize != dictionarySize)
254
-      {
255
-        dictionarySize = newDictionarySize;
256
-        if (dictionary)
257
-          lzmafree(dictionary);
258
-        dictionary = lzmaalloc(dictionarySize);
259
-        if (!dictionary)
260
-          return LZMA_NOT_ENOUGH_MEM;
261
-      }
262
-
263
-      dictionary[dictionarySize - 1] = 0;
264
-
265
-      i = 5;
266
-      while (i--)
267
-      {
268
-        NEED_BYTE(LZMA_C_RDI);
269
-        code = (code << 8) | NEXT_BYTE;
270
-      }
271
-    }
272
-  case LZMA_C_BLOCK:
273
-    posState = (int)(totalOut & posStateMask);
274
-    DECODE_BIT(LZMA_C_TYPE, p + IsMatch + (state << kNumPosBitsMax) + posState);
275
-    if (bit == 0)
276
-    {
277
-      probs = p + Literal + (LZMA_LIT_SIZE *
278
-        (((totalOut & literalPosMask) << lc) + (previousByte >> (8 - lc))));
279
-
280
-      if (state < 4) state = 0;
281
-      else if (state < 10) state -= 3;
282
-      else state -= 6;
283
-      if (isPreviousMatch)
284
-      {
285
-        UInt32 pos = dictionaryPos - rep0;
286
-        if (pos >= dictionarySize)
287
-          pos += dictionarySize;
288
-        matchByte = dictionary[pos];
289
-        {
290
-          symbol = 1;
291
-          do
292
-          {
293
-            matchBit = (matchByte >> 7) & 1;
294
-            matchByte <<= 1;
295
-            {
296
-              prob = probs + ((1 + matchBit) << 8) + symbol;
297
-              RC_GET_BIT2(LZMA_C_LITDM1, prob, symbol, bit = 0, bit = 1)
298
-            }
299
-            if (matchBit != bit)
300
-            {
301
-              while (symbol < 0x100)
302
-              {
303
-                prob = probs + symbol;
304
-                RC_GET_BIT(LZMA_C_LITDM2, prob, symbol)
305
-              }
306
-              break;
307
-            }
308
-          }
309
-          while (symbol < 0x100);
310
-          previousByte = symbol;
311
-        }
312
-        isPreviousMatch = 0;
313
-      }
314
-      else
315
-      {
316
-        symbol = 1;
317
-        do
318
-        {
319
-          prob = probs + symbol;
320
-          RC_GET_BIT(LZMA_C_LITD, prob, symbol)
321
-        }
322
-        while (symbol < 0x100);
323
-        previousByte = symbol;
324
-      }
325
-      NEED_OUT(LZMA_C_OUTPUT_1);
326
-      PUT_BYTE(previousByte);
327
-      dictionary[dictionaryPos] = previousByte;
328
-      dictionaryPos = (dictionaryPos + 1) % dictionarySize;
329
-    }
330
-    /* bit == 1 */
331
-    else
332
-    {
333
-      isPreviousMatch = 1;
334
-      DECODE_BIT(LZMA_C_ISREP, p + IsRep + state);
335
-      if (bit == 1)
336
-      {
337
-        DECODE_BIT(LZMA_C_ISREPG0, p + IsRepG0 + state);
338
-        if (bit == 0)
339
-        {
340
-          DECODE_BIT(LZMA_C_ISREP0LONG, p + IsRep0Long + (state << kNumPosBitsMax) + posState);
341
-          if (bit == 0)
342
-          {
343
-            UInt32 pos;
344
-            if (totalOut == 0)
345
-              return LZMA_DATA_ERROR;
346
-            state = state < 7 ? 9 : 11;
347
-            NEED_OUT(LZMA_C_OUTPUT_2);
348
-            pos = dictionaryPos - rep0;
349
-            if (pos >= dictionarySize)
350
-              pos += dictionarySize;
351
-            previousByte = dictionary[pos];
352
-            dictionary[dictionaryPos] = previousByte;
353
-            dictionaryPos = (dictionaryPos + 1) % dictionarySize;
354
-            PUT_BYTE(previousByte);
355
-            mode = LZMA_C_BLOCK;
356
-            break;
357
-          }
358
-        }
359
-        else
360
-        {
361
-          UInt32 distance;
362
-          DECODE_BIT(LZMA_C_ISREPG1, p + IsRepG1 + state);
363
-          if (bit == 0)
364
-          {
365
-            distance = rep1;
366
-          }
367
-          else
368
-          {
369
-            DECODE_BIT(LZMA_C_ISREPG2, p + IsRepG2 + state);
370
-            if (bit == 0)
371
-              distance = rep2;
372
-            else
373
-            {
374
-              distance = rep3;
375
-              rep3 = rep2;
376
-            }
377
-            rep2 = rep1;
378
-          }
379
-          rep1 = rep0;
380
-          rep0 = distance;
381
-        }
382
-        DECODE_LEN(LZMA_C_LEND_C1, p + RepLenCoder);
383
-        state = state < 7 ? 8 : 11;
384
-      }
385
-      else
386
-      {
387
-        rep3 = rep2;
388
-        rep2 = rep1;
389
-        rep1 = rep0;
390
-        state = state < 7 ? 7 : 10;
391
-        DECODE_LEN(LZMA_C_LEND_C2, p + LenCoder);
392
-        DECODE_BIT_TREE(
393
-          LZMA_C_BTD_C1,
394
-          p + PosSlot + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits),
395
-          kNumPosSlotBits
396
-        );
397
-        if (posSlot >= kStartPosModelIndex)
398
-        {
399
-          int numDirectBits = ((posSlot >> 1) - 1);
400
-          rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits);
401
-          if (posSlot < kEndPosModelIndex)
402
-          {
403
-            probs = p + SpecPos + rep0 - posSlot - 1;
404
-            numLevels = numDirectBits;
405
-          }
406
-          else
407
-          {
408
-            int numTotalBits = numDirectBits - kNumAlignBits;
409
-            result = 0;
410
-            for (i = numTotalBits; i > 0; i--)
411
-            {
412
-              /* UInt32 t; */
413
-              range >>= 1;
414
-
415
-              result <<= 1;
416
-              if (code >= range)
417
-              {
418
-                code -= range;
419
-                result |= 1;
420
-              }
421
-              /*
422
-              t = (code - range) >> 31;
423
-              t &= 1;
424
-              code -= range & (t - 1);
425
-              result = (result + result) | (1 - t);
426
-              */
427
-              RC_NORMALIZE(LZMA_C_NORM)
428
-            }
429
-            rep0 += result << kNumAlignBits;
430
-            probs = p + Align;
431
-            numLevels = kNumAlignBits;
432
-          }
433
-          mi = 1;
434
-          symbol = 0;
435
-          for(i = 0; i < numLevels; i++)
436
-          {
437
-            prob = probs + mi;
438
-            RC_GET_BIT2(LZMA_C_RDRBTD, prob, mi, ; , symbol |= (1 << i));
439
-          }
440
-          rep0 += symbol;
441
-        }
442
-        else
443
-          rep0 = posSlot;
444
-        rep0++;
445
-      }
446
-      if (rep0 == (UInt32)(0))
447
-      {
448
-        len = -1;
449
-        LEAVE;
450
-      }
451
-      if (rep0 > totalOut)
452
-      {
453
-        return LZMA_DATA_ERROR;
454
-      }
455
-      len += kMatchMinLen;
456
-      totalOut += len;
457
-      do
458
-      {
459
-        UInt32 pos;
460
-        NEED_OUT(LZMA_C_OUTPUT_3);
461
-        pos = dictionaryPos - rep0;
462
-        if (pos >= dictionarySize)
463
-          pos += dictionarySize;
464
-        previousByte = dictionary[pos];
465
-        dictionary[dictionaryPos] = previousByte;
466
-        dictionaryPos = (dictionaryPos + 1) % dictionarySize;
467
-        PUT_BYTE_(previousByte);
468
-        len--;
469
-      }
470
-      while(len > 0);
471
-    }
472
-    mode = LZMA_C_BLOCK;
473
-    break;
474
-  case LZMA_C_RDBD:
475
-  _LZMA_C_RDBD:
476
-    {
477
-      UInt32 bound = (range >> kNumBitModelTotalBits) * *prob;
478
-      if (code < bound)
479
-      {
480
-        range = bound;
481
-        *prob += (kBitModelTotal - *prob) >> kNumMoveBits;
482
-        bit = 0;
483
-      }
484
-      else
485
-      {
486
-        range -= bound;
487
-        code -= bound;
488
-        *prob -= (*prob) >> kNumMoveBits;
489
-        bit = 1;
490
-      }
491
-      RC_NORMALIZE(LZMA_C_RDBD_IN);
492
-    }
493
-    mode = last;
494
-    break;
495
-  case LZMA_C_LEND:
496
-  _LZMA_C_LEND:
497
-      DECODE_BIT(LZMA_C_LEND1, probs + LenChoice);
498
-      if (bit == 0)
499
-      {
500
-        len = 0;
501
-        probs += LenLow + (posState << kLenNumLowBits);
502
-        numLevels = kLenNumLowBits;
503
-      }
504
-      else {
505
-        DECODE_BIT(LZMA_C_LEND2, probs + LenChoice2);
506
-        if (bit == 0)
507
-        {
508
-          len = kLenNumLowSymbols;
509
-          probs += + LenMid + (posState << kLenNumMidBits);
510
-          numLevels = kLenNumMidBits;
511
-        }
512
-        else
513
-        {
514
-          len = kLenNumLowSymbols + kLenNumMidSymbols;
515
-          probs += LenHigh;
516
-          numLevels = kLenNumHighBits;
517
-        }
518
-      }
519
-
520
-      last3 = LZMA_C_LEND_RES;
521
-  case LZMA_C_BTD:
522
-  _LZMA_C_BTD:
523
-    mi = 1;
524
-    for(i = numLevels; i > 0; i--)
525
-    {
526
-      prob = probs + mi;
527
-      RC_GET_BIT(LZMA_C_BTD_LOOP, prob, mi)
528
-    }
529
-    result = mi - (1 << numLevels);
530
-    mode = last3;
531
-    break;
532
-  case LZMA_C_LEND_RES:
533
-    len += result;
534
-    mode = last2;
535
-    break;
536
-  default:
537
-    return LZMA_DATA_ERROR;
538
-  }
539
-
540
-saveStateAndReturn:
541
-
542
-  /* save decoder state */
543
-  *s = _s;
544
-
545
-  return LZMA_OK;
546
-}
547
-
548
-
549
-/* aCaB */
550
-void lzmaShutdown(lzma_stream *s) {
551
-  lzma_stream _s = *s;
552
-  if (p) lzmafree(p);
553
-  if (dictionary) lzmafree(dictionary);
554
-  p = NULL;
555
-  dictionary = NULL;
556
-  *s = _s;
557
-}
558 1
deleted file mode 100644
... ...
@@ -1,126 +0,0 @@
1
-/*
2
- * LZMADecode.c
3
- * 
4
- * This file is a part of LZMA compression module for NSIS.
5
- * 
6
- * Original LZMA SDK Copyright (C) 1999-2006 Igor Pavlov
7
- * Modifications Copyright (C) 2003-2007 Amir Szekely <kichik@netvision.net.il>
8
- * 
9
- * Licensed under the Common Public License version 1.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * 
12
- * Licence details can be found in the file COPYING.nsis.
13
- * 
14
- * This software is provided 'as-is', without any express or implied
15
- * warranty.
16
- */
17
-
18
-#ifndef __LZMADECODE_H
19
-#define __LZMADECODE_H
20
-
21
-/* #define _LZMA_PROB32 */
22
-/* It can increase speed on some 32-bit CPUs, 
23
-   but memory usage will be doubled in that case */
24
-
25
-#ifdef __cplusplus
26
-extern "C" {
27
-#endif
28
-
29
-#include "others.h"
30
-
31
-#ifndef lzmaalloc
32
-#define lzmaalloc cli_malloc
33
-#endif
34
-
35
-#ifndef lzmafree
36
-#define lzmafree free
37
-#endif
38
-
39
-#ifndef LZMACALL
40
-#  define LZMACALL
41
-#endif
42
-
43
-#ifndef UInt32
44
-#ifdef _LZMA_UINT32_IS_ULONG
45
-#define UInt32 unsigned long
46
-#else
47
-#define UInt32 unsigned int
48
-#endif
49
-#endif
50
-
51
-#ifdef _LZMA_PROB32
52
-#define CProb UInt32
53
-#else
54
-#define CProb unsigned short
55
-#endif
56
-
57
-typedef unsigned char lzByte;
58
-
59
-#define LZMA_STREAM_END 1
60
-#define LZMA_OK 0
61
-#define LZMA_DATA_ERROR -1
62
-/* we don't really care what the problem is... */
63
-/* #define LZMA_RESULT_NOT_ENOUGH_MEM -2 */
64
-#define LZMA_NOT_ENOUGH_MEM -1
65
-
66
-typedef struct
67
-{
68
-  /* mode control */
69
-  int mode;
70
-  int last;
71
-  int last2;
72
-  int last3;
73
-
74
-  /* properties */
75
-  UInt32 dynamicDataSize;
76
-  UInt32 dictionarySize;
77
-
78
-  /* io */
79
-  lzByte *next_in;    /* next input byte */
80
-  UInt32 avail_in;  /* number of bytes available at next_in */
81
-
82
-  lzByte *next_out;   /* next output byte should be put there */
83
-  UInt32 avail_out; /* remaining free space at next_out */
84
-
85
-  UInt32 totalOut;  /* total output - not always correct when lzmaDecode returns */
86
-
87
-  /* saved state */
88
-  lzByte previousByte;
89
-  lzByte matchByte;
90
-  CProb *probs;
91
-  CProb *prob;
92
-  int mi;
93
-  int posState;
94
-  int temp1;
95
-  int temp2;
96
-  int temp3;
97
-  int lc;
98
-  int state;
99
-  int isPreviousMatch;
100
-  int len;
101
-  UInt32 rep0;
102
-  UInt32 rep1;
103
-  UInt32 rep2;
104
-  UInt32 rep3;
105
-  UInt32 posStateMask;
106
-  UInt32 literalPosMask;
107
-  UInt32 dictionaryPos;
108
-
109
-  /* range coder */
110
-  UInt32 range;
111
-  UInt32 code;
112
-
113
-  /* allocated buffers */
114
-  lzByte *dictionary;
115
-  lzByte *dynamicData;
116
-} lzma_stream;
117
-
118
-void LZMACALL lzmaInit(lzma_stream *);
119
-int LZMACALL lzmaDecode(lzma_stream *);
120
-void LZMACALL lzmaShutdown(lzma_stream *); /* aCaB */
121
-
122
-#ifdef __cplusplus
123
-}
124
-#endif
125
-
126
-#endif
... ...
@@ -13,7 +13,7 @@
13 13
    This file was modified for ClamAV by aCaB <acab@clamav.net>
14 14
 
15 15
    This program is released under the terms of the license contained
16
-   in the file COPYING.nsis.
16
+   in the file COPYING.bzip2.
17 17
    ------------------------------------------------------------------ */
18 18
 
19 19
 /* CHANGES
... ...
@@ -13,7 +13,7 @@
13 13
    This file was modified for ClamAV by aCaB <acab@clamav.net>
14 14
 
15 15
    This program is released under the terms of the license contained
16
-   in the file COPYING.nsis.
16
+   in the file COPYING.bzip2.
17 17
    ------------------------------------------------------------------ */
18 18
 
19 19
 
20 20
deleted file mode 100644
... ...
@@ -1,715 +0,0 @@
1
-/*
2
- * This file is a part of the zlib compression module for NSIS.
3
- * 
4
- * Copyright and license information can be found below.
5
- * Modifications Copyright (C) 1999-2007 Nullsoft and Contributors
6
- * 
7
- * The original zlib source code is available at
8
- * http://www.zlib.net/
9
- * 
10
- * This software is provided 'as-is', without any express or implied
11
- * warranty.
12
- */
13
-
14
-/*
15
- * Copyright (C) 1995-1998 Jean-loup Gailly.
16
- * For conditions of distribution and use, see copyright notice in COPYING.nsis
17
- */
18
-
19
-#include "nsis_zutil.h"
20
-#include <string.h>
21
-
22
-#ifndef min
23
-#  define min(x,y) ((x<y)?x:y)
24
-#endif
25
-
26
-/* defines for inflate input/output */
27
-/*   update pointers and return */
28
-#define UPDBITS {s->bitb=b;s->bitk=k;}
29
-#define UPDIN {z->avail_in=n;z->next_in=p;}
30
-#define UPDOUT {s->write=q;}
31
-#define UPDATE {UPDBITS UPDIN UPDOUT}
32
-#define LEAVE(r) {UPDATE inflate_flush(z); return r;}
33
-
34
-/*   get bytes and bits */
35
-#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
36
-
37
-
38
-#define NEEDBYTE {if(!n)LEAVE(Z_OK)}
39
-#define NEXTBYTE (n--,*p++)
40
-#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
41
-
42
-#define DUMPBITS(j) {b>>=(j);k-=(j);}
43
-/*   output bytes */
44
-#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
45
-#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
46
-#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
47
-#define FLUSH {UPDOUT inflate_flush(z); LOADOUT}
48
-#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE(Z_OK)}}}
49
-#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
50
-/*   load local pointers */
51
-#define LOAD {LOADIN LOADOUT}
52
-
53
-#define LAST (s->last == DRY)
54
-
55
-#define FIXEDH 544      /* number of hufts used by fixed tables */
56
-
57
-
58
-
59
-typedef struct inflate_blocks_state FAR inflate_blocks_statef;
60
-#define exop word.what.Exop
61
-#define bits word.what.Bits
62
-
63
-/* And'ing with mask[n] masks the lower n bits */
64
-local unsigned short inflate_mask[17] = {
65
-    0x0000,
66
-    0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
67
-    0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
68
-}; /* use to reduce .data #define INFLATE_MASK(x, n) (x & (~((unsigned short) 0xFFFF << n))) */
69
-local const char border[] = { /* Order of the bit length code lengths */
70
-        16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
71
-
72
-/* Tables for deflate from PKZIP's appnote.txt. */
73
-local const unsigned short  cplens[31] = { /* Copy lengths for literal codes 257..285 */
74
-        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
75
-        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
76
-        /* see note #13 above about 258 */
77
-local const unsigned short  cplext[31] = { /* Extra bits for literal codes 257..285 */
78
-        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
79
-        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
80
-local const unsigned short  cpdist[30] = { /* Copy offsets for distance codes 0..29 */
81
-        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
82
-        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
83
-        8193, 12289, 16385, 24577};
84
-local const unsigned short  cpdext[30] = { /* Extra bits for distance codes */
85
-        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
86
-        7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
87
-        12, 12, 13, 13};
88
-
89
-/* build fixed tables only once--keep them here */
90
-local char fixed_built = 0;
91
-local inflate_huft fixed_mem[FIXEDH];
92
-local uInt fixed_bl=9;
93
-local uInt fixed_bd=5;
94
-local inflate_huft *fixed_tl;
95
-local inflate_huft *fixed_td;
96
-
97
-/* copy as much as possible from the sliding window to the output area */
98
-local void ZEXPORT inflate_flush(nsis_z_streamp z)
99
-{
100
-  inflate_blocks_statef *s = &z->blocks;
101
-  uInt n;
102
-  Bytef *q;
103
-
104
-  /* local copies of source and destination pointers */
105
-  q = s->read;
106
-
107
-again:
108
-  /* compute number of bytes to copy as far as end of window */
109
-  n = (uInt)((q <= s->write ? s->write : s->end) - q);
110
-  n = min(n, z->avail_out);
111
-
112
-  /* update counters */
113
-  z->avail_out -= n;
114
-  /* z->total_out += n; */
115
-
116
-  /* copy as far as end of window */
117
-  zmemcpy(z->next_out, q, n);
118
-  z->next_out += n;
119
-  q += n;
120
-
121
-  /* see if more to copy at beginning of window */
122
-  if (q == s->end)
123
-  {
124
-    /* wrap pointers */
125
-    q = s->window;
126
-    if (s->write == s->end)
127
-      s->write = s->window;
128
-
129
-    /* do the same for the beginning of the window */
130
-    goto again;
131
-  }
132
-
133
-  /* update pointers */
134
-  s->read = q;
135
-}
136
-
137
-#define BMAX 15         /* maximum bit length of any code */
138
-
139
-local int ZEXPORT huft_build(
140
-uIntf *b,               /* code lengths in bits (all assumed <= BMAX) */
141
-uInt n,                 /* number of codes (assumed <= 288) */
142
-uInt s,                 /* number of simple-valued codes (0..s-1) */
143
-const unsigned short *d,         /* list of base values for non-simple codes */
144
-const unsigned short *e,         /* list of extra bits for non-simple codes */
145
-inflate_huft * FAR *t,  /* result: starting table */
146
-uIntf *m,               /* maximum lookup bits, returns actual */
147
-inflate_huft *hp,       /* space for trees */
148
-uInt *hn)               /* working area: values in order of bit length */
149
-{
150
-  static uIntf v[288];             /* work area for huft_build */
151
-  uInt a;                       /* counter for codes of length k */
152
-  uInt c[BMAX+1];               /* bit length count table */
153
-  uInt f;                       /* i repeats in table every f entries */
154
-  int g;                        /* maximum code length */
155
-  int h;                        /* table level */
156
-  uInt i;              /* counter, current code */
157
-  uInt j;              /* counter */
158
-  int k;               /* number of bits in current code */
159
-  int l;                        /* bits per table (returned in m) */
160
-  uIntf *p;            /* pointer into c[], b[], or v[] */
161
-  inflate_huft *q;              /* points to current table */
162
-  struct inflate_huft_s r;      /* table entry for structure assignment */
163
-  inflate_huft *u[BMAX];        /* table stack */
164
-  int w;               /* bits before this table == (l * h) */
165
-  uInt x[BMAX+1];               /* bit offsets, then code stack */
166
-  uIntf *xp;                    /* pointer into x */
167
-  int y;                        /* number of dummy codes added */
168
-  uInt z;                       /* number of entries in current table */
169
-
170
-
171
-  /* Generate counts for each bit length */
172
-  p=c;
173
-  y=16; while (y--) *p++ = 0;
174
-  p = b;
175
-  i = n;
176
-  do {
177
-    c[*p++]++;                  /* assume all entries <= BMAX */
178
-  } while (--i);
179
-  if (c[0] == n)                /* null input--all zero length codes */
180
-  {
181
-    *t = (inflate_huft *)Z_NULL;
182
-    *m = 0;
183
-    return Z_OK;
184
-  }
185
-
186
-
187
-  /* Find minimum and maximum length, bound *m by those */
188
-  l = *m;
189
-  for (j = 1; j <= BMAX; j++)
190
-    if (c[j])
191
-      break;
192
-  k = j;                        /* minimum code length */
193
-  if ((uInt)l < j)
194
-    l = j;
195
-  for (i = BMAX; i; i--)
196
-    if (c[i])
197
-      break;
198
-  g = i;                        /* maximum code length */
199
-  if ((uInt)l > i)
200
-    l = i;
201
-  *m = l;
202
-
203
-
204
-  /* Adjust last length count to fill out codes, if needed */
205
-  for (y = 1 << j; j < i; j++, y <<= 1)
206
-    if ((y -= c[j]) < 0)
207
-      return Z_DATA_ERROR;
208
-  if ((y -= c[i]) < 0)
209
-    return Z_DATA_ERROR;
210
-  c[i] += y;
211
-
212
-
213
-  /* Generate starting offsets into the value table for each length */
214
-  x[1] = j = 0;
215
-  p = c + 1;  xp = x + 2;
216
-  while (--i) {                 /* note that i == g from above */
217
-    *xp++ = (j += *p++);
218
-  }
219
-
220
-
221
-  /* Make a table of values in order of bit lengths */
222
-  p = b;  i = 0;
223
-  do {
224
-    if ((j = *p++) != 0)
225
-      v[x[j]++] = i;
226
-  } while (++i < n);
227
-  n = x[g];                     /* set n to length of v */
228
-
229
-
230
-  /* Generate the Huffman codes and for each, make the table entries */
231
-  x[0] = i = 0;                 /* first Huffman code is zero */
232
-  p = v;                        /* grab values in bit order */
233
-  h = -1;                       /* no tables yet--level -1 */
234
-  w = -l;                       /* bits decoded == (l * h) */
235
-  u[0] = (inflate_huft *)Z_NULL;        /* just to keep compilers happy */
236
-  q = (inflate_huft *)Z_NULL;   /* ditto */
237
-  z = 0;                        /* ditto */
238
-
239
-  r.base = 0;
240
-
241
-  /* go through the bit lengths (k already is bits in shortest code) */
242
-  for (; k <= g; k++)
243
-  {
244
-    a = c[k];
245
-    while (a--)
246
-    {
247
-      int nextw=w;
248
-      /* here i is the Huffman code of length k bits for value *p */
249
-      /* make tables up to required level */
250
-      while (k > (nextw=w + l))
251
-      {
252
-        h++;
253
-
254
-        /* compute minimum size table less than or equal to l bits */
255
-        z = g - nextw;
256
-        z = z > (uInt)l ? (uInt)l : z;        /* table size upper limit */
257
-        if ((f = 1 << (j = k - nextw)) > a + 1)     /* try a k-w bit table */
258
-        {                       /* too few codes for k-w bit table */
259
-          f -= a + 1;           /* deduct codes from patterns left */
260
-          xp = c + k;
261
-          if (j < z)
262
-            while (++j < z && (f <<= 1) > *++xp)     /* try smaller tables up to z bits */
263
-            {
264
-              f -= *xp;         /* else deduct codes from patterns */
265
-            }
266
-        }
267
-        z = 1 << j;             /* table entries for j-bit table */
268
-
269
-        /* allocate new table */
270
-        if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */
271
-          return Z_MEM_ERROR;   /* not enough memory */
272
-        u[h] = q = hp + *hn;
273
-        *hn += z;
274
-
275
-        /* connect to last table, if there is one */
276
-        if (h)
277
-        {
278
-          x[h] = i;             /* save pattern for backing up */
279
-          r.bits = (Byte)l;     /* bits to dump before this table */
280
-          r.exop = (Byte)j;     /* bits in this table */
281
-          j = i >> w;
282
-          r.base = (uInt)(q - u[h-1] - j);   /* offset to this table */
283
-          u[h-1][j] = r;        /* connect to last table */
284
-        }
285
-        else
286
-          *t = q;               /* first table is returned result */
287
-        w=nextw;                 /* previous table always l bits */
288
-      }
289
-
290
-      /* set up table entry in r */
291
-      r.bits = (Byte)(k - w);
292
-      if (p >= v + n)
293
-        r.exop = 128 + 64;      /* out of values--invalid code */
294
-      else if (*p < s)
295
-      {
296
-        r.exop = (Byte)(*p < 256 ? 0 : 32 + 64);     /* 256 is end-of-block */
297
-        r.base = *p++;          /* simple code is just the value */
298
-      }
299
-      else
300
-      {
301
-        r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
302
-        r.base = d[*p++ - s];
303
-      }
304
-
305
-      /* fill code-like entries with r */
306
-      f = 1 << (k - w);
307
-      for (j = i >> w; j < z; j += f)
308
-        q[j] = r;
309
-
310
-      /* backwards increment the k-bit code i */
311
-      for (j = 1 << (k - 1); i & j; j >>= 1)
312
-        i ^= j;
313
-      i ^= j;
314
-
315
-      /* backup over finished tables */
316
-      while ((i & ((1 << w) - 1)) != x[h])
317
-      {
318
-        h--;                    /* don't need to update q */
319
-        w -= l;
320
-      }
321
-    }
322
-  }
323
-
324
-
325
-  /* Return Z_BUF_ERROR if we were given an incomplete table */
326
-  return (y != 0 && g != 1) ? Z_BUF_ERROR : Z_OK;
327
-}
328
-
329
-int ZEXPORT nsis_inflate(nsis_z_streamp z)
330
-{
331
-  inflate_blocks_statef *s = &z->blocks;
332
-  inflate_codes_statef *c = &s->sub.decode.t_codes;  /* codes state */
333
-
334
-  /* lousy two bytes saved by doing this */
335
-  struct
336
-  {
337
-    uInt t;               /* temporary storage */
338
-    uLong b;              /* bit buffer */
339
-    uInt k;               /* bits in bit buffer */
340
-    Bytef *p;             /* input data pointer */
341
-    uInt n;               /* bytes available there */
342
-    Bytef *q;             /* output window write pointer */
343
-    uInt m;               /* bytes to end of window or read pointer */
344
-
345
-    /* CODES variables */
346
-
347
-    inflate_huft *j;      /* temporary pointer */
348
-    uInt e;               /* extra bits or operation */
349
-    Bytef *f;             /* pointer to copy strings from */
350
-  } _state;
351
-
352
-#define t _state.t
353
-#define b _state.b
354
-#define k _state.k
355
-#define p _state.p
356
-#define n _state.n
357
-#define q _state.q
358
-#define m _state.m
359
-
360
-  /* copy input/output information to locals (UPDATE macro restores) */
361
-  LOAD
362
-
363
-  /* process input based on current state */
364
-  for (;;) switch (s->mode)
365
-  {
366
-    case TYPE:
367
-      NEEDBITS(3)
368
-      t = (uInt)b & 7;
369
-      DUMPBITS(3)
370
-      s->last = (t & 1) ? DRY : TYPE;
371
-      switch (t >> 1)
372
-      {
373
-        case 0:                         /* stored */
374
-          Tracev((stderr, "inflate:     stored block%s\n",
375
-                 LAST ? " (last)" : ""));
376
-          DUMPBITS(k&7)
377
-          s->mode = LENS;               /* get length of stored block */
378
-          break;
379
-        case 1:                         /* fixed */
380
-          Tracev((stderr, "inflate:     fixed codes block%s\n",
381
-                 LAST ? " (last)" : ""));
382
-          {
383
-            if (!fixed_built)
384
-            {
385
-              int _k;              /* temporary variable */
386
-              uInt f = 0;         /* number of hufts used in fixed_mem */
387
-              static uIntf lc[288];           /* length list for huft_build */
388
-
389
-              /* literal table */
390
-              for (_k = 0; _k < 288; _k++)
391
-              {
392
-                char v=8;
393
-                if (_k > 143)
394
-                {
395
-                  if (_k < 256) v++;
396
-                  else if (_k < 280) v--;
397
-                }
398
-                lc[_k] = v;
399
-              }
400
-
401
-              huft_build(lc, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, fixed_mem, &f);
402
-
403
-              /* distance table */
404
-              for (_k = 0; _k < 30; _k++) lc[_k] = 5;
405
-
406
-              huft_build(lc, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, fixed_mem, &f);
407
-
408
-              /* done */
409
-              fixed_built++;
410
-            }
411
-
412
-            /* s->sub.decode.t_codes.mode = CODES_START; */
413
-            s->sub.decode.t_codes.lbits = (Byte)fixed_bl;
414
-            s->sub.decode.t_codes.dbits = (Byte)fixed_bd;
415
-            s->sub.decode.t_codes.ltree = fixed_tl;
416
-            s->sub.decode.t_codes.dtree = fixed_td;
417
-          }
418
-          s->mode = CODES_START;
419
-          break;
420
-        case 2:                         /* dynamic */
421
-          Tracev((stderr, "inflate:     dynamic codes block%s\n",
422
-                 LAST ? " (last)" : ""));
423
-          s->mode = TABLE;
424
-          break;
425
-        case 3:                         /* illegal */
426
-          /* the only illegal value possible is 3 because we check only 2 bits */
427
-          goto bad;
428
-      }
429
-      break;
430
-    case LENS:
431
-      NEEDBITS(16)
432
-      s->sub.left = (uInt)b & 0xffff;
433
-      b = k = 0;                      /* dump bits */
434
-      Tracev((stderr, "inflate:       stored length %u\n", s->sub.left));
435
-      s->mode = s->sub.left ? STORED : (inflate_mode)s->last;
436
-      break;
437
-    case STORED:
438
-    {
439
-      uInt mn;
440
-
441
-      if (n == 0)
442
-        LEAVE(Z_OK)
443
-      NEEDOUT
444
-      mn = min(m, n);
445
-      t = min(s->sub.left, mn);
446
-      zmemcpy(q, p, t);
447
-      p += t;  n -= t;
448
-      q += t;  m -= t;
449
-      if (!(s->sub.left -= t))
450
-        s->mode = (inflate_mode)s->last;
451
-      break;
452
-    }
453
-    case TABLE:
454
-      NEEDBITS(14)
455
-      s->sub.trees.table = t = (uInt)b & 0x3fff;
456
-      if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
457
-      {
458
-        s->mode = NZ_BAD;
459
-        LEAVE(Z_DATA_ERROR);
460
-      }
461
-      /* t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); */
462
-      DUMPBITS(14)
463
-      s->sub.trees.index = 0;
464
-      Tracev((stderr, "inflate:       table sizes ok\n"));
465
-      s->mode = BTREE;
466
-    case BTREE:
467
-      while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
468
-      {
469
-        NEEDBITS(3)
470
-        s->sub.trees.t_blens[(int)border[s->sub.trees.index++]] = (uInt)b & 7;
471
-        DUMPBITS(3)
472
-      }
473
-      while (s->sub.trees.index < 19)
474
-        s->sub.trees.t_blens[(int)border[s->sub.trees.index++]] = 0;
475
-      s->sub.trees.bb = 7;
476
-
477
-      {
478
-        uInt hn = 0;          /* hufts used in space */
479
-
480
-        t = huft_build(s->sub.trees.t_blens, 19, 19, Z_NULL, Z_NULL,
481
-		       &s->sub.trees.tb, &s->sub.trees.bb, s->hufts, &hn);
482
-        if (t != Z_OK || !s->sub.trees.bb)
483
-        {
484
-          s->mode = NZ_BAD;
485
-          break;
486
-        }
487
-      }
488
-
489
-      s->sub.trees.index = 0;
490
-      Tracev((stderr, "inflate:       bits tree ok\n"));
491
-      s->mode = DTREE;
492
-    case DTREE:
493
-      while (t = s->sub.trees.table,
494
-             s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
495
-      {
496
-        inflate_huft *h;
497
-        uInt i, j, d;
498
-
499
-        t = s->sub.trees.bb;
500
-        NEEDBITS(t)
501
-        h = s->sub.trees.tb + ((uInt)b & (uInt)inflate_mask[t]);
502
-        t = h->bits;
503
-        d = h->base;
504
-        if (d < 16)
505
-        {
506
-          DUMPBITS(t)
507
-          s->sub.trees.t_blens[s->sub.trees.index++] = d;
508
-        }
509
-        else /* d == 16..18 */
510
-        {
511
-          if (d == 18)
512
-          {
513
-            i=7;
514
-            j=11;
515
-          }
516
-          else
517
-          {
518
-            i=d-14;
519
-            j=3;
520
-          }
521
-          NEEDBITS(t+i)
522
-          DUMPBITS(t)
523
-          j += (uInt)b & (uInt)inflate_mask[i];
524
-          DUMPBITS(i)
525
-          i = s->sub.trees.index;
526
-          t = s->sub.trees.table;
527
-          if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
528
-              (d == 16 && i < 1))
529
-          {
530
-            s->mode = NZ_BAD;
531
-            LEAVE(Z_DATA_ERROR);
532
-          }
533
-          d = d == 16 ? s->sub.trees.t_blens[i - 1] : 0;
534
-          do {
535
-            s->sub.trees.t_blens[i++] = d;
536
-          } while (--j);
537
-          s->sub.trees.index = i;
538
-        }
539
-      }
540
-      s->sub.trees.tb = Z_NULL;
541
-      {
542
-        uInt hn = 0;          /* hufts used in space */
543
-        uInt bl, bd;
544
-        inflate_huft *tl, *td;
545
-        int nl,nd;
546
-        t = s->sub.trees.table;
547
-
548
-        nl = 257 + (t & 0x1f);
549
-        nd = 1 + ((t >> 5) & 0x1f);
550
-        bl = 9;         /* must be <= 9 for lookahead assumptions */
551
-        bd = 6;         /* must be <= 9 for lookahead assumptions */
552
-
553
-        t = huft_build(s->sub.trees.t_blens, nl, 257, cplens, cplext, &tl, &bl, s->hufts, &hn);
554
-        if (bl == 0) t = Z_DATA_ERROR;
555
-        if (t == Z_OK)
556
-        {
557
-          /* build distance tree */
558
-          t = huft_build(s->sub.trees.t_blens + nl, nd, 0, cpdist, cpdext, &td, &bd, s->hufts, &hn);
559
-        }
560
-        if (t != Z_OK || (bd == 0 && nl > 257))
561
-        {
562
-          s->mode = NZ_BAD;
563
-          LEAVE(Z_DATA_ERROR);
564
-        }
565
-        Tracev((stderr, "inflate:       trees ok\n"));
566
-
567
-        /* s->sub.decode.t_codes.mode = CODES_START; */
568
-        s->sub.decode.t_codes.lbits = (Byte)bl;
569
-        s->sub.decode.t_codes.dbits = (Byte)bd;
570
-        s->sub.decode.t_codes.ltree = tl;
571
-        s->sub.decode.t_codes.dtree = td;
572
-      }
573
-      s->mode = CODES_START;
574
-
575
-#define j (_state.j)
576
-#define e (_state.e)
577
-#define f (_state.f)
578
-
579
-    /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
580
-
581
-    case CODES_START:         /* x: set up for LEN */
582
-      c->sub.code.need = c->lbits;
583
-      c->sub.code.tree = c->ltree;
584
-      s->mode = CODES_LEN;
585
-    case CODES_LEN:           /* i: get length/literal/eob next */
586
-      t = c->sub.code.need;
587
-      NEEDBITS(t)
588
-      j = c->sub.code.tree + ((uInt)b & (uInt)inflate_mask[t]);
589
-      DUMPBITS(j->bits)
590
-      e = (uInt)(j->exop);
591
-      if (e == 0)               /* literal */
592
-      {
593
-        c->sub.lit = j->base;
594
-        s->mode = CODES_LIT;
595
-        break;
596
-      }
597
-      if (e & 16)               /* length */
598
-      {
599
-        c->sub.copy.get = e & 15;
600
-        c->len = j->base;
601
-        s->mode = CODES_LENEXT;
602
-        break;
603
-      }
604
-      if ((e & 64) == 0)        /* next table */
605
-      {
606
-        c->sub.code.need = e;
607
-        c->sub.code.tree = j + j->base;
608
-        break;
609
-      }
610
-      if (e & 32)               /* end of block */
611
-      {
612
-        s->mode = CODES_WASH;
613
-        break;
614
-      }
615
-    goto bad;
616
-    case CODES_LENEXT:        /* i: getting length extra (have base) */
617
-      t = c->sub.copy.get;
618
-      NEEDBITS(t)
619
-      c->len += (uInt)b & (uInt)inflate_mask[t];
620
-      DUMPBITS(t)
621
-      c->sub.code.need = c->dbits;
622
-      c->sub.code.tree = c->dtree;
623
-      s->mode = CODES_DIST;
624
-    case CODES_DIST:          /* i: get distance next */
625
-      t = c->sub.code.need;
626
-      NEEDBITS(t)
627
-      j = c->sub.code.tree + ((uInt)b & (uInt)inflate_mask[t]);
628
-      DUMPBITS(j->bits)
629
-      e = (uInt)(j->exop);
630
-      if (e & 16)               /* distance */
631
-      {
632
-        c->sub.copy.get = e & 15;
633
-        c->sub.copy.dist = j->base;
634
-        s->mode = CODES_DISTEXT;
635
-        break;
636
-      }
637
-      if ((e & 64) == 0)        /* next table */
638
-      {
639
-        c->sub.code.need = e;
640
-        c->sub.code.tree = j + j->base;
641
-        break;
642
-      }
643
-      goto bad;        /* invalid code */
644
-    case CODES_DISTEXT:       /* i: getting distance extra */
645
-      t = c->sub.copy.get;
646
-      NEEDBITS(t)
647
-      c->sub.copy.dist += (uInt)b & (uInt)inflate_mask[t];
648
-      DUMPBITS(t)
649
-      s->mode = CODES_COPY;
650
-    case CODES_COPY:          /* o: copying bytes in window, waiting for space */
651
-      f = (uInt)(q - s->window) < c->sub.copy.dist ?
652
-          s->end - (c->sub.copy.dist - (q - s->window)) :
653
-          q - c->sub.copy.dist;
654
-
655
-      while (c->len)
656
-      {
657
-        NEEDOUT
658
-        OUTBYTE(*f++)
659
-        if (f == s->end)
660
-          f = s->window;
661
-        c->len--;
662
-      }
663
-      s->mode = CODES_START;
664
-      break;
665
-    case CODES_LIT:           /* o: got literal, waiting for output space */
666
-      NEEDOUT
667
-      OUTBYTE(c->sub.lit)
668
-      s->mode = CODES_START;
669
-      break;
670
-    case CODES_WASH:          /* o: got eob, possibly more output */
671
-      if (k > 7)        /* return unused byte, if any */
672
-      {
673
-        k -= 8;
674
-        n++;
675
-        p--;            /* can always return one */
676
-      }
677
-      /* flushing will be done in DRY */
678
-
679
-#undef j
680
-#undef e
681
-#undef f
682
-
683
-    case DRY:
684
-      FLUSH
685
-      if (s->write != s->read)
686
-        LEAVE(Z_OK)
687
-      if (s->mode == CODES_WASH)
688
-      {
689
-        Tracev((stderr, "inflate:       codes end, %lu total out\n",
690
-               z->total_out + (q >= s->read ? q - s->read :
691
-               (s->end - s->read) + (q - s->window))));
692
-      }
693
-      /* DRY if last, TYPE if not */
694
-      s->mode = (inflate_mode)s->last;
695
-      if (s->mode == TYPE)
696
-        break;
697
-      LEAVE(Z_STREAM_END)
698
-    /*case BAD:
699
-      r = Z_DATA_ERROR;
700
-      LEAVE
701
-    */
702
-    default: /* we'll call Z_STREAM_ERROR if BAD anyway */
703
-    bad:
704
-      s->mode = NZ_BAD;
705
-      LEAVE(Z_STREAM_ERROR)
706
-  }
707
-}
708
-
709
-#undef t
710
-#undef b
711
-#undef k
712
-#undef p
713
-#undef n
714
-#undef q
715
-#undef m
... ...
@@ -13,7 +13,7 @@
13 13
    This file was modified for ClamAV by aCaB <acab@clamav.net>
14 14
 
15 15
    This program is released under the terms of the license contained
16
-   in the file COPYING.nsis.
16
+   in the file COPYING.bzip2.
17 17
    ------------------------------------------------------------------ */
18 18
 
19 19
 
20 20
deleted file mode 100644
... ...
@@ -1,58 +0,0 @@
1
-/* zconf.h -- configuration of the zlib compression library
2
- * Copyright (C) 1995-1998 Jean-loup Gailly.
3
- * For conditions of distribution and use, see copyright notice in COPYING.nsis.
4
- */
5
-
6
-/* @(#) $Id: ZCONF.H,v 1.3 2007/01/13 17:28:23 kichik Exp $ */
7
-
8
-#ifndef _ZCONF_H
9
-#define _ZCONF_H
10
-
11
-
12
-#define MAX_MEM_LEVEL 9
13
-
14
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
15
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
16
- * created by gzip. (Files created by minigzip can still be extracted by
17
- * gzip.)
18
- */
19
-#ifndef MAX_WBITS
20
-#  define MAX_WBITS   15 /* 32K LZ77 window */
21
-#endif
22
-
23
-#define OF(args)  args
24
-
25
-
26
-#ifndef ZEXPORT
27
-#  define ZEXPORT
28
-#endif
29
-#ifndef ZEXPORTVA
30
-#  define ZEXPORTVA
31
-#endif
32
-#ifndef ZEXTERN
33
-#  define ZEXTERN extern
34
-#endif
35
-
36
-#ifndef FAR
37
-#  define FAR
38
-#endif
39
-
40
-typedef unsigned char  Byte;  /* 8 bits */
41
-typedef unsigned int   uInt;  /* 16 bits or more */
42
-typedef unsigned long  uLong; /* 32 bits or more */
43
-
44
-typedef Byte  FAR Bytef;
45
-typedef char  FAR charf;
46
-typedef int   FAR intf;
47
-typedef uInt  FAR uIntf;
48
-typedef uLong FAR uLongf;
49
-
50
-typedef void FAR *voidpf;
51
-typedef void     *voidp;
52
-
53
-#ifndef z_off_t
54
-#  define  z_off_t long
55
-#endif
56
-
57
-
58
-#endif /* _ZCONF_H */
59 1
deleted file mode 100644
... ...
@@ -1,220 +0,0 @@
1
-/* zlib.h -- interface of the 'zlib' general purpose compression library
2
-  version 1.1.3, July 9th, 1998
3
-
4
-  Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
5
-
6
-  This software is provided 'as-is', without any express or implied
7
-  warranty.  In no event will the authors be held liable for any damages
8
-  arising from the use of this software.
9
-
10
-  Permission is granted to anyone to use this software for any purpose,
11
-  including commercial applications, and to alter it and redistribute it
12
-  freely, subject to the following restrictions:
13
-
14
-  1. The origin of this software must not be misrepresented; you must not
15
-     claim that you wrote the original software. If you use this software
16
-     in a product, an acknowledgment in the product documentation would be
17
-     appreciated but is not required.
18
-  2. Altered source versions must be plainly marked as such, and must not be
19
-     misrepresented as being the original software.
20
-  3. This notice may not be removed or altered from any source distribution.
21
-
22
-  Jean-loup Gailly        Mark Adler
23
-  jloup@gzip.org          madler@alumni.caltech.edu
24
-
25
-
26
-*/
27
-
28
-#ifndef _NSIS_ZLIB_H
29
-#define _NSIS_ZLIB_H
30
-
31
-#include "nsis_zconf.h"
32
-#include "nsis_zutil.h"
33
-
34
-#ifdef __cplusplus
35
-extern "C" {
36
-#endif
37
-
38
-
39
-typedef struct inflate_huft_s FAR inflate_huft;
40
-
41
-
42
-
43
-typedef enum {        /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
44
-      CODES_START,    /* x: set up for LEN */
45
-      CODES_LEN,      /* i: get length/literal/eob next */
46
-      CODES_LENEXT,   /* i: getting length extra (have base) */
47
-      CODES_DIST,     /* i: get distance next */
48
-      CODES_DISTEXT,  /* i: getting distance extra */
49
-      CODES_COPY,     /* o: copying bytes in window, waiting for space */
50
-      CODES_LIT,      /* o: got literal, waiting for output space */
51
-      CODES_WASH,     /* o: got eob, possibly still output waiting */
52
-      /* CODES_END,      x: got eob and all data flushed */
53
-      /* CODES_BADCODE,  x: got error */
54
-
55
-      TYPE,     /* get type bits (3, including end bit) */
56
-      LENS,     /* get lengths for stored */
57
-      STORED,   /* processing stored block */
58
-      TABLE,    /* get table lengths */
59
-      BTREE,    /* get bit lengths tree for a dynamic block */
60
-      DTREE,    /* get length, distance trees for a dynamic block */
61
-      CODES,    /* processing fixed or dynamic block */
62
-      DRY,      /* output remaining window bytes */
63
-      DONE,     /* finished last block, done */
64
-      NZ_BAD       /* got a data error--stuck here */
65
-} inflate_mode;
66
-
67
-/* inflate codes private state */
68
-struct inflate_codes_state {
69
-
70
-  /* mode */
71
-  /* inflate_mode mode;      current inflate_codes mode */
72
-
73
-  /* mode dependent information */
74
-  uInt len;
75
-  union {
76
-    struct {
77
-      inflate_huft *tree;       /* pointer into tree */
78
-      uInt need;                /* bits needed */
79
-    } code;             /* if LEN or DIST, where in tree */
80
-    uInt lit;           /* if LIT, literal */
81
-    struct {
82
-      uInt get;                 /* bits to get for extra */
83
-      uInt dist;                /* distance back to copy from */
84
-    } copy;             /* if EXT or COPY, where and how much */
85
-  } sub;                /* submode */
86
-
87
-  /* mode independent information */
88
-  Byte lbits;           /* ltree bits decoded per branch */
89
-  Byte dbits;           /* dtree bits decoder per branch */
90
-  inflate_huft *ltree;          /* literal/length/eob tree */
91
-  inflate_huft *dtree;          /* distance tree */
92
-
93
-};
94
-
95
-struct inflate_huft_s {
96
-  union {
97
-    struct {
98
-      Byte Exop;        /* number of extra bits or operation */
99
-      Byte Bits;        /* number of bits in this code or subcode */
100
-    } what;
101
-  } word;
102
-  unsigned short base;            /* literal, length base, distance base,
103
-                           or table offset */
104
-};
105
-
106
-#define MANY 1440
107
-
108
-typedef struct inflate_codes_state inflate_codes_statef;
109
-
110
-struct inflate_blocks_state {
111
-
112
-  /* mode */
113
-  inflate_mode  mode;    /* current inflate_block mode */
114
-
115
-  /* mode dependent information */
116
-  union {
117
-    uInt left;          /* if STORED, bytes left to copy */
118
-    struct {
119
-      uInt table;               /* table lengths (14 bits) */
120
-      uInt index;               /* index into blens (or border) */
121
-      uIntf t_blens[258+31+31];             /* bit lengths of codes */
122
-      uInt bb;                  /* bit length tree depth */
123
-      inflate_huft *tb;         /* bit length decoding tree */
124
-    } trees;            /* if DTREE, decoding info for trees */
125
-    struct {
126
-      inflate_codes_statef t_codes;
127
-    } decode;           /* if CODES, current state */
128
-  } sub;                /* submode */
129
-
130
-  uInt last;            /* DRY if this block is the last block, TYPE otherwise */
131
-
132
-  /* mode independent information */
133
-  uInt bitk;            /* bits in bit buffer */
134
-  uLong bitb;           /* bit buffer */
135
-  inflate_huft hufts[MANY];  /* single malloc for tree space */
136
-  Bytef window[1 << MAX_WBITS];        /* sliding window */
137
-  Bytef *end;           /* one byte after sliding window */
138
-  Bytef *read;          /* window read pointer */
139
-  Bytef *write;         /* window write pointer */
140
-  uLong check;          /* check on output */
141
-
142
-};
143
-
144
-typedef struct nsis_z_stream_s {
145
-    Bytef    *next_in;  /* next input byte */
146
-    uInt     avail_in;  /* number of bytes available at next_in */
147
-    uLong    total_in;  /* total nb of input bytes read so far */
148
-
149
-    Bytef    *next_out; /* next output byte should be put there */
150
-    uInt     avail_out; /* remaining free space at next_out */
151
-
152
-    /* char     *msg;      last error message, NULL if no error */
153
-    /* struct internal_state FAR *state; not visible by applications */
154
-    struct inflate_blocks_state blocks;
155
-
156
-} nsis_z_stream;
157
-
158
-typedef nsis_z_stream FAR *nsis_z_streamp;
159
-
160
-
161
-#define Z_NO_FLUSH      0
162
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
163
-#define Z_SYNC_FLUSH    2
164
-#define Z_FULL_FLUSH    3
165
-#define Z_FINISH        4
166
-/* Allowed flush values; see deflate() below for details */
167
-
168
-#define Z_OK            0
169
-#define Z_STREAM_END    1
170
-#define Z_NEED_DICT     2
171
-#define Z_ERRNO        (-1)
172
-
173
-/* EXEHEAD doesn't need a specific return code, just < 0 */
174
-#define Z_STREAM_ERROR (-2)
175
-#define Z_DATA_ERROR   (-3)
176
-#define Z_MEM_ERROR    (-4)
177
-#define Z_BUF_ERROR    (-5)
178
-#define Z_VERSION_ERROR (-6)
179
-
180
-/* Return codes for the compression/decompression functions. Negative
181
- * values are errors, positive values are used for special but normal events.
182
- */
183
-
184
-#define Z_NO_COMPRESSION         0
185
-#define Z_BEST_SPEED             1
186
-#define Z_BEST_COMPRESSION       9
187
-#define Z_DEFAULT_COMPRESSION  (-1)
188
-/* compression levels */
189
-
190
-#define Z_FILTERED            1
191
-#define Z_HUFFMAN_ONLY        2
192
-#define Z_DEFAULT_STRATEGY    0
193
-/* compression strategy; see deflateInit2() below for details */
194
-
195
-#define Z_BINARY   0
196
-#define Z_ASCII    1
197
-#define Z_UNKNOWN  2
198
-/* Possible values of the data_type field */
199
-
200
-#define Z_DEFLATED   8
201
-/* The deflate compression method (the only one supported in this version) */
202
-
203
-#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
204
-
205
-
206
-#define nsis_inflateInit(x) inflateReset(x)
207
-int ZEXPORT nsis_inflate(nsis_z_streamp z);
208
-#define inflateReset(z) \
209
-{ \
210
-  (z)->blocks.mode = TYPE; \
211
-  (z)->blocks.bitk = (z)->blocks.bitb = 0; \
212
-  (z)->blocks.read = (z)->blocks.write = (z)->blocks.window; \
213
-  (z)->blocks.end = (z)->blocks.window + (1 << DEF_WBITS); \
214
-}
215
-
216
-#ifdef __cplusplus
217
-}
218
-#endif
219
-
220
-#endif /* _ZLIB_H */
221 1
deleted file mode 100644
... ...
@@ -1,74 +0,0 @@
1
-/*
2
- * This file is a part of the zlib compression module for NSIS.
3
- * 
4
- * Copyright and license information can be found below.
5
- * Modifications Copyright (C) 1999-2007 Nullsoft and Contributors
6
- * 
7
- * The original zlib source code is available at
8
- * http://www.zlib.net/
9
- * 
10
- * This software is provided 'as-is', without any express or implied
11
- * warranty.
12
- */
13
-
14
-/* zutil.h -- internal interface and configuration of the compression library
15
- * Copyright (C) 1995-1998 Jean-loup Gailly.
16
- * For conditions of distribution and use, see copyright notice in COPYING.nsis.
17
- */
18
-
19
-/* WARNING: this file should *not* be used by applications. It is
20
-   part of the implementation of the compression library and is
21
-   subject to change. Applications should only use zlib.h.
22
- */
23
-
24
-/* @(#) $Id: ZUTIL.H,v 1.6 2007/01/25 18:07:40 kichik Exp $ */
25
-
26
-#ifndef _Z_UTIL_H
27
-#define _Z_UTIL_H
28
-
29
-#include "nsis_zlib.h"
30
-
31
-#ifndef local
32
-#  define local static
33
-#endif
34
-
35
-typedef unsigned char  uch;
36
-typedef uch FAR uchf;
37
-typedef unsigned short ush;
38
-typedef ush FAR ushf;
39
-typedef unsigned long  ulg;
40
-
41
-#ifndef DEF_WBITS
42
-#  define DEF_WBITS MAX_WBITS
43
-#endif
44
-/* default windowBits for decompression. MAX_WBITS is for compression only */
45
-
46
-#define DEF_MEM_LEVEL  MAX_MEM_LEVEL
47
-
48
-#define STORED_BLOCK 0
49
-#define STATIC_TREES 1
50
-#define DYN_TREES    2
51
-/* The three kinds of block type */
52
-
53
-#define MIN_MATCH  3
54
-#define MAX_MATCH  258
55
-/* The minimum and maximum match lengths */
56
-
57
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
58
-
59
-
60
-#define zmemcpy memcpy
61
-
62
-#define Assert(cond,msg)
63
-#define Trace(x)
64
-#define Tracev(x)
65
-#define Tracevv(x)
66
-#define Tracec(c,x)
67
-#define Tracecv(c,x)
68
-
69
-#define ZALLOC(strm, items, size) malloc((items)*(size))
70
-#define ZFREE(strm, addr)  { if (addr) free(addr); }
71
-#define TRY_FREE(s, p) { ZFREE(s, p); }
72
-#define ERR_RETURN(strm,err) return (err)
73
-
74
-#endif /* _Z_UTIL_H */
... ...
@@ -32,8 +32,8 @@
32 32
 #include "others.h"
33 33
 #include "cltypes.h"
34 34
 #include "nsis_bzlib.h"
35
-#include "LZMADecode.h"
36
-#include "nsis_zlib.h"
35
+#include "lzma_iface.h"
36
+#include "zlib.h"
37 37
 #include "matcher.h"
38 38
 #include "scanners.h"
39 39
 #include "nulsft.h" /* SHUT UP GCC -Wextra */
... ...
@@ -67,8 +67,8 @@ struct nsis_st {
67 67
     unsigned char *next_out;
68 68
   } nsis;
69 69
   nsis_bzstream bz;
70
-  lzma_stream lz;
71
-  nsis_z_stream z;
70
+  CLI_LZMA lz;
71
+  z_stream z;
72 72
   unsigned char *freeme;
73 73
   uint8_t comp;
74 74
   uint8_t solid;
... ...
@@ -85,16 +85,19 @@ struct nsis_st {
85 85
 static int nsis_init(struct nsis_st *n) {
86 86
   switch(n->comp) {
87 87
   case COMP_BZIP2:
88
+    memset(&n->bz, 0, sizeof(nsis_bzstream));
88 89
     if (nsis_BZ2_bzDecompressInit(&n->bz, 0, 0)!=BZ_OK)
89 90
       return CL_EBZIP;
90 91
     n->freecomp=1;
91 92
     break;
92 93
   case COMP_LZMA:
93
-    lzmaInit(&n->lz);
94
+    memset(&n->lz, 0, sizeof(CLI_LZMA));
95
+    cli_LzmaInit(&n->lz, 0xffffffffffffffff);
94 96
     n->freecomp=1;
95 97
     break;
96 98
   case COMP_ZLIB:
97
-    nsis_inflateInit(&n->z);
99
+    memset(&n->bz, 0, sizeof(z_stream));
100
+    inflateInit2(&n->z, -MAX_WBITS);
98 101
     n->freecomp=0;
99 102
   }
100 103
   return CL_SUCCESS;
... ...
@@ -109,8 +112,9 @@ static void nsis_shutdown(struct nsis_st *n) {
109 109
     nsis_BZ2_bzDecompressEnd(&n->bz);
110 110
     break;
111 111
   case COMP_LZMA:
112
-    lzmaShutdown(&n->lz);
112
+    cli_LzmaShutdown(&n->lz);
113 113
   case COMP_ZLIB:
114
+    inflateEnd(&n->z);
114 115
     break;
115 116
   }
116 117
 
... ...
@@ -142,8 +146,8 @@ static int nsis_decomp(struct nsis_st *n) {
142 142
     n->lz.next_in = n->nsis.next_in;
143 143
     n->lz.avail_out = n->nsis.avail_out;
144 144
     n->lz.next_out = n->nsis.next_out;
145
-    switch (lzmaDecode(&n->lz)) {
146
-    case LZMA_OK:
145
+    switch (cli_LzmaDecode(&n->lz)) {
146
+    case LZMA_RESULT_OK:
147 147
       ret = CL_SUCCESS;
148 148
       break;
149 149
     case LZMA_STREAM_END:
... ...
@@ -159,12 +163,13 @@ static int nsis_decomp(struct nsis_st *n) {
159 159
     n->z.next_in = n->nsis.next_in;
160 160
     n->z.avail_out = n->nsis.avail_out;
161 161
     n->z.next_out = n->nsis.next_out;
162
-    switch (nsis_inflate(&n->z)) {
162
+    switch (inflate(&n->z, Z_NO_FLUSH)) {
163 163
     case Z_OK:
164 164
       ret = CL_SUCCESS;
165 165
       break;
166 166
     case Z_STREAM_END:
167 167
       ret = CL_BREAK;
168
+    /* FIXME: regression needed */ 
168 169
     }
169 170
     n->nsis.avail_in = n->z.avail_in;
170 171
     n->nsis.next_in = n->z.next_in;
... ...
@@ -1850,103 +1850,63 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1850 1850
 
1851 1851
     /* WWPack */
1852 1852
 
1853
-    if((DCONF & PE_CONF_WWPACK) && nsections > 1 &&
1854
-       exe_sections[nsections-1].raw>0x2b1 &&
1853
+    while ((DCONF & PE_CONF_WWPACK) && nsections > 1 &&
1855 1854
        vep == exe_sections[nsections - 1].rva &&
1856
-       exe_sections[nsections - 1].rva + exe_sections[nsections - 1].rsz == max &&
1857 1855
        memcmp(epbuff, "\x53\x55\x8b\xe8\x33\xdb\xeb", 7) == 0 &&
1858 1856
        memcmp(epbuff+0x68, "\xe8\x00\x00\x00\x00\x58\x2d\x6d\x00\x00\x00\x50\x60\x33\xc9\x50\x58\x50\x50", 19) == 0)  {
1859
-	uint32_t headsize=exe_sections[nsections - 1].raw;
1860
-	char *dest, *wwp;
1857
+	uint32_t head = exe_sections[nsections - 1].raw;
1858
+        uint8_t *packer;
1861 1859
 
1862
-	for(i = 0 ; i < (unsigned int)nsections-1; i++)
1863
-	    if (exe_sections[i].raw<headsize) headsize=exe_sections[i].raw;
1864
-      
1865
-	dsize = max-min+headsize-exe_sections[nsections - 1].rsz;
1860
+	ssize = 0;
1861
+	for(i=0 ; ; i++) {
1862
+	    if(exe_sections[i].raw<head) 
1863
+	        head=exe_sections[i].raw;
1864
+	    if(i==nsections-1) break;
1865
+	    if(ssize<exe_sections[i].rva+exe_sections[i].vsz)
1866
+		ssize=exe_sections[i].rva+exe_sections[i].vsz;
1867
+	}
1868
+	if(!head || !ssize || head>ssize) break;
1866 1869
 
1867
-	CLI_UNPSIZELIMITS("WWPack", dsize);
1870
+	CLI_UNPSIZELIMITS("WWPack", ssize);
1868 1871
 
1869
-	if((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) {
1870
-	    cli_dbgmsg("WWPack: Can't allocate %d bytes\n", dsize);
1872
+        if(!(src=(char *)cli_calloc(ssize, sizeof(char)))) {
1871 1873
 	    free(exe_sections);
1872 1874
 	    return CL_EMEM;
1873 1875
 	}
1874
-
1875 1876
 	lseek(desc, 0, SEEK_SET);
1876
-	if((size_t) cli_readn(desc, dest, headsize) != headsize) {
1877
-	    cli_dbgmsg("WWPack: Can't read %d bytes from headers\n", headsize);
1878
-	    free(dest);
1877
+	if((size_t) cli_readn(desc, src, head) != head) {
1878
+	    cli_dbgmsg("WWPack: Can't read %d bytes from headers\n", head);
1879
+	    free(src);
1879 1880
 	    free(exe_sections);
1880 1881
 	    return CL_EIO;
1881 1882
 	}
1882
-
1883
-	for(i = 0 ; i < (unsigned int)nsections-1; i++) {
1884
-	    if(exe_sections[i].rsz) {
1885
-		if(!cli_seeksect(desc, &exe_sections[i]) || (unsigned int) cli_readn(desc, dest + headsize + exe_sections[i].rva - min, exe_sections[i].rsz) != exe_sections[i].rsz) {
1886
-		    free(dest);
1887
-		    free(exe_sections);
1888
-		    return CL_EIO;
1889
-		}
1890
-	    }
1891
-	}
1892
-
1893
-	if((wwp = (char *) cli_calloc(exe_sections[nsections - 1].rsz, sizeof(char))) == NULL) {
1894
-	    cli_dbgmsg("WWPack: Can't allocate %d bytes\n", exe_sections[nsections - 1].rsz);
1895
-	    free(dest);
1883
+        for(i = 0 ; i < (unsigned int)nsections-1; i++) {
1884
+	    if(!exe_sections[i].rsz) continue;
1885
+	    if(!cli_seeksect(desc, &exe_sections[i])) break;
1886
+            if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break;
1887
+            if(cli_readn(desc, src+exe_sections[i].rva, exe_sections[i].rsz)!=exe_sections[i].rsz) break;
1888
+        }
1889
+        if(i!=nsections-1) {
1890
+            cli_dbgmsg("WWpack: Probably hacked/damaged file.\n");
1891
+            free(src);
1892
+            break;
1893
+        }
1894
+	if((packer = (char *) cli_calloc(exe_sections[nsections - 1].rsz, sizeof(char))) == NULL) {
1895
+	    free(src);
1896 1896
 	    free(exe_sections);
1897 1897
 	    return CL_EMEM;
1898 1898
 	}
1899
-
1900
-	if(!cli_seeksect(desc, &exe_sections[nsections - 1]) || (size_t) cli_readn(desc, wwp, exe_sections[nsections - 1].rsz) != exe_sections[nsections - 1].rsz) {
1899
+	if(!cli_seeksect(desc, &exe_sections[nsections - 1]) || (size_t) cli_readn(desc, packer, exe_sections[nsections - 1].rsz) != exe_sections[nsections - 1].rsz) {
1901 1900
 	    cli_dbgmsg("WWPack: Can't read %d bytes from wwpack sect\n", exe_sections[nsections - 1].rsz);
1902
-	    free(dest);
1903
-	    free(wwp);
1901
+	    free(src);
1902
+	    free(packer);
1904 1903
 	    free(exe_sections);
1905 1904
 	    return CL_EIO;
1906 1905
 	}
1907 1906
 
1908
-	if (!wwunpack(dest, dsize, headsize, min, exe_sections[nsections-1].rva, e_lfanew, wwp, exe_sections[nsections - 1].rsz, nsections-1)) {
1909
-	
1910
-	    free(wwp);
1911
-
1912
-	    CLI_UNPTEMP("WWPack",(dest,exe_sections,0));
1913
-
1914
-	    if((unsigned int) write(ndesc, dest, dsize) != dsize) {
1915
-		cli_dbgmsg("WWPack: Can't write %d bytes\n", dsize);
1916
-		close(ndesc);
1917
-		free(tempfile);
1918
-		free(dest);
1919
-		free(exe_sections);
1920
-		return CL_EIO;
1921
-	    }
1922
-
1923
-	    free(dest);
1924
-	    if (cli_leavetemps_flag)
1925
-		cli_dbgmsg("WWPack: Unpacked and rebuilt executable saved in %s\n", tempfile);
1926
-	    else
1927
-		cli_dbgmsg("WWPack: Unpacked and rebuilt executable\n");
1928
-
1929
-	    fsync(ndesc);
1930
-	    lseek(ndesc, 0, SEEK_SET);
1931
-
1932
-	    if(cli_magic_scandesc(ndesc, ctx) == CL_VIRUS) {
1933
-		free(exe_sections);
1934
-		close(ndesc);
1935
-		if(!cli_leavetemps_flag)
1936
-		    unlink(tempfile);
1937
-		free(tempfile);
1938
-		return CL_VIRUS;
1939
-	    }
1940
-
1941
-	    close(ndesc);
1942
-	    if(!cli_leavetemps_flag)
1943
-		unlink(tempfile);
1944
-	    free(tempfile);
1945
-	} else {
1946
-	    free(wwp);
1947
-	    free(dest);
1948
-	    cli_dbgmsg("WWPpack: Decompression failed\n");
1949
-	}
1907
+	CLI_UNPTEMP("WWPack",(src,packer,exe_sections,0));
1908
+	CLI_UNPRESULTS("WWPack",(wwunpack(src, ssize, packer, exe_sections, nsections-1, e_lfanew, ndesc)),0,(src,packer,0));
1909
+	break;
1950 1910
     }
1951 1911
 
1952 1912
 
... ...
@@ -64,34 +64,30 @@
64 64
 * Phishing design documentation,
65 65
 (initially written at http://wiki.clamav.net/index.php/phishing_design as discussed with aCaB)
66 66
 
67
-TODO:update this doc
68
-
69
-*Warning*: if flag *--phish-scan-alldomains* (or equivalent clamd/clamav-milter config option) isn't given, then phishing scanning is done only for domains listed in daily.pdb.
70
-If your daily.pdb is empty, then by default NO PHISHING is DONE, UNLESS you give the *--phish-scan-alldomains*
71
-This is just a side-effect, daily.pdb is empty, because it isn't yet officialy in daily.cvd.
67
+TODO: update this doc whenever behaviour changes
72 68
 
73 69
 phishingCheck() determines if @displayedLink is  a legit representation of @realLink.
74 70
 
75 71
 Steps:
76 72
 
77
-1. if _realLink_ *==* _displayLink_ => *CLEAN*
73
+1. if _realLink_ == _displayLink_ => CLEAN
78 74
 
79 75
 2. url cleanup (normalization)
80 76
 - whitespace elimination
77
+ strip all spaces, and leading and trailing garbage.
78
+ When matching we have to keep in account whether we stripped any spaces or not.
79
+ See str_fixup_spaces.
81 80
 - html entity conversion
81
+- handle hex-encoded characters
82 82
 - convert hostname to lowercase
83 83
 - normalize \ to /
84
-If there is a dot after the last space, then all spaces are replaced with dots,
85
-otherwise spaces are stripped.
86
-So both: 'Go to yahoo.com', and 'Go to e b a y . c o m', and 'Go to ebay. com' will work.
87
-
88 84
 
89 85
 3. Matched the urls against a _whitelist_:
90 86
 a _realLink_, _displayedLink_ pair is matched against the _whitelist_.
91 87
 the _whitelist_ is a list of pairs of realLink, displayedLink. Any of the elements of those pairs can be a _regex_.
92 88
  if url *is found* in _whitelist_ --> *CLEAN*
93 89
 
94
-4. URL is looked up in the _domainlist_, unless disabled via flags (_--phish-scan-alldomains_).
90
+4. URL is looked up in the _domainlist_
95 91
 The _domainlist_ is a list of pairs of realLink, displayedLink (any of which can be regex).
96 92
 This is the list of domains we do phishing detection for (such as ebay,paypal,chase,....)
97 93
 We can't decide to stop processing here or not, so we just set a flag.
... ...
@@ -120,7 +116,6 @@ Checks if realLink is http, but displayedLink is https or viceversa.
120 120
 12. Numeric IP detection.
121 121
 If url is a numeric IP, then -> phish.
122 122
 Maybe we should do DNS lookup?
123
-Maybe we should disable numericIP checks for --phish-scan-alldomains?
124 123
 
125 124
 13. isURL(displayedLink).
126 125
 Checks if displayedLink is really a url.
... ...
@@ -227,21 +222,21 @@ static const char numeric_url_regex[] = "^ *"URI_numeric_fragmentaddress" *$";
227 227
 
228 228
 /* generated by contrib/phishing/generate_tables.c */
229 229
 static const short int hextable[256] = {
230
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
231
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
232
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
233
-       0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
234
-       0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
235
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
236
-       0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
237
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
238
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
239
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
240
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
241
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
242
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
243
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
244
-       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
230
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
231
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
232
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
233
+       0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
234
+       0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
235
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
236
+       0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
237
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
238
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
239
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
240
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
241
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
242
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
243
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
244
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
245 245
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
246 246
 };
247 247
 
... ...
@@ -352,13 +347,13 @@ static int build_regex(regex_t* preg,const char* regex,int nosub)
352 352
 	cli_dbgmsg("Phishcheck: Compiling regex: %s\n",regex);
353 353
 	rc = cli_regcomp(preg,regex,REG_EXTENDED|REG_ICASE|(nosub ? REG_NOSUB :0));
354 354
 	if(rc) {
355
-	
355
+
356 356
 #ifdef	C_WINDOWS
357 357
 		cli_errmsg("Phishcheck: Error in compiling regex, disabling phishing checks\n");
358 358
 #else
359 359
 		size_t buflen =	cli_regerror(rc,preg,NULL,0);
360 360
 		char *errbuf = cli_malloc(buflen);
361
-		
361
+
362 362
 		if(errbuf) {
363 363
 			cli_regerror(rc,preg,errbuf,buflen);
364 364
 			cli_errmsg("Phishcheck: Error in compiling regex:%s\nDisabling phishing checks\n",errbuf);
... ...
@@ -682,7 +677,7 @@ cleanupURL(struct string *URL,struct string *pre_URL, int isReal)
682 682
 	char *begin = URL->data;
683 683
 	const char *end;
684 684
 	size_t len;
685
-	
685
+
686 686
 	clear_msb(begin);
687 687
 	/*if(begin == NULL)
688 688
 		return;*/
... ...
@@ -776,16 +771,13 @@ int phishingScan(message* m,const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs)
776 776
 		if(hrefs->contents[i]) {
777 777
 			struct url_check urls;
778 778
 			enum phish_status rc;
779
-			urls.always_check_flags = DOMAINLIST_REQUIRED;/* required to work correctly */
780 779
 			urls.flags	 = strncmp((char*)hrefs->tag[i],href_text,href_text_len)? (CL_PHISH_ALL_CHECKS&~CHECK_SSL): CL_PHISH_ALL_CHECKS;
781 780
 			urls.link_type   = 0;
782 781
 			if(!strncmp((char*)hrefs->tag[i],src_text,src_text_len)) {
783 782
 				if (!(urls.flags&CHECK_IMG_URL))
784 783
 				continue;
785
-				urls.link_type |= LINKTYPE_IMAGE; 
784
+				urls.link_type |= LINKTYPE_IMAGE;
786 785
 			}
787
-			if (ctx->options&CL_SCAN_PHISHING_DOMAINLIST)
788
-				urls.flags |= DOMAINLIST_REQUIRED;
789 786
 			if (ctx->options & CL_SCAN_PHISHING_BLOCKSSL) {
790 787
 				urls.always_check_flags |= CHECK_SSL;
791 788
 			}
... ...
@@ -817,20 +809,6 @@ int phishingScan(message* m,const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs)
817 817
 			switch(rc)/*TODO: support flags from ctx->options,*/
818 818
 				{
819 819
 					case CL_PHISH_CLEAN:
820
-					case CL_PHISH_CLEANUP_OK:
821
-					case CL_PHISH_HOST_OK:
822
-					case CL_PHISH_DOMAIN_OK:
823
-					case CL_PHISH_REDIR_OK:
824
-					case CL_PHISH_HOST_REDIR_OK:
825
-					case CL_PHISH_DOMAIN_REDIR_OK:
826
-					case CL_PHISH_HOST_REVERSE_OK:
827
-					case CL_PHISH_DOMAIN_REVERSE_OK:
828
-					case CL_PHISH_WHITELISTED:
829
-					case CL_PHISH_HOST_WHITELISTED:
830
-					case CL_PHISH_MAILTO_OK:
831
-					case CL_PHISH_TEXTURL:
832
-					case CL_PHISH_HOST_NOT_LISTED:
833
-					case CL_PHISH_CLEAN_CID:
834 820
 						continue;
835 821
 /*						break;*/
836 822
 					case CL_PHISH_HEX_URL:
... ...
@@ -929,7 +907,7 @@ int phishing_init(struct cl_engine* engine)
929 929
 		free_regex(&pchk->preg_cctld);
930 930
 		free(pchk);
931 931
 		engine->phishcheck = NULL;
932
-		return CL_EFORMAT;	
932
+		return CL_EFORMAT;
933 933
 	}
934 934
 	url_regex = str_compose("^ *(("URI_CHECK_PROTOCOLS")|("URI_fragmentaddress1,URI_fragmentaddress2,URI_fragmentaddress3")) *$");
935 935
 	if(build_regex(&pchk->preg,url_regex,1)) {
... ...
@@ -986,7 +964,7 @@ void phishing_done(struct cl_engine* engine)
986 986
 		cli_dbgmsg("Freeing phishcheck struct\n");
987 987
 		free(pchk);
988 988
 		engine->phishcheck = NULL;
989
-	}		
989
+	}
990 990
 	cli_dbgmsg("Phishcheck cleaned up\n");
991 991
 }
992 992
 
... ...
@@ -1023,7 +1001,7 @@ static enum phish_status cleanupURLs(struct url_check* urls)
1023 1023
 		if(!urls->displayLink.data || !urls->realLink.data)
1024 1024
 			return CL_PHISH_NODECISION;
1025 1025
 		if(!strcmp(urls->realLink.data,urls->displayLink.data))
1026
-			return CL_PHISH_CLEANUP_OK;
1026
+			return CL_PHISH_CLEAN;
1027 1027
 	}
1028 1028
 	return CL_PHISH_NODECISION;
1029 1029
 }
... ...
@@ -1040,33 +1018,31 @@ static int url_get_host(const struct phishcheck* pchk, struct url_check* url,str
1040 1040
 	if(!start || !end) {
1041 1041
 		string_assign_null(host);
1042 1042
 	}
1043
-	else {
1044
-		if(( rc = string_assign_dup(host,start,end) ))
1045
-			return rc;
1043
+	else if(( rc = string_assign_dup(host,start,end) )) {
1044
+		return rc;
1046 1045
 	}
1046
+
1047 1047
 	cli_dbgmsg("Phishcheck:host:%s\n", host->data);
1048
-	if(!isReal) {
1049
-		url->pre_fixup.host_start = start - URL;
1050
-		url->pre_fixup.host_end = end - URL;
1051
-	}
1052
-	if(!host->data)
1053
-		return CL_PHISH_CLEANUP_OK;
1054
-	if(*phishy&REAL_IS_MAILTO)
1055
-		return CL_PHISH_MAILTO_OK;
1056
-	if(strchr(host->data,' ')) {
1057
-		string_free(host);
1058
-		return CL_PHISH_TEXTURL;
1048
+
1049
+	if(!host->data || (isReal && host->data[0]=='\0') || *phishy&REAL_IS_MAILTO || strchr(host->data,' ')) {
1050
+		/* no host,
1051
+		 * link without domain, such as: href="/isapi.dll?...
1052
+		 * mailto:
1053
+		 * spaces in hostname
1054
+		 */
1055
+		return CL_PHISH_CLEAN;
1059 1056
 	}
1060 1057
 	if(url->flags&CHECK_CLOAKING && !cli_regexec(&pchk->preg_hexurl,host->data,0,NULL,0)) {
1061 1058
 		/* uses a regex here, so that we don't accidentally block 0xacab.net style hosts */
1062
-		string_free(host);
1063 1059
 		return CL_PHISH_HEX_URL;
1064 1060
 	}
1065
-	if(isReal && host->data[0]=='\0')
1066
-		return CL_PHISH_CLEAN;/* link without domain, such as: href="/isapi.dll?... */
1067 1061
 	if(isNumeric(host->data)) {
1068 1062
 		*phishy |= PHISHY_NUMERIC_IP;
1069 1063
 	}
1064
+	if(!isReal) {
1065
+		url->pre_fixup.host_start = start - URL;
1066
+		url->pre_fixup.host_end = end - URL;
1067
+	}
1070 1068
 	return CL_PHISH_NODECISION;
1071 1069
 }
1072 1070
 
... ...
@@ -1105,45 +1081,15 @@ static int whitelist_check(const struct cl_engine* engine,struct url_check* urls
1105 1105
 	return whitelist_match(engine,urls->realLink.data,urls->displayLink.data,hostOnly);
1106 1106
 }
1107 1107
 
1108
-static int isPhishing(enum phish_status rc)
1109
-{
1110
-	switch(rc) {
1111
-		case CL_PHISH_CLEAN:
1112
-		case CL_PHISH_CLEANUP_OK:
1113
-		case CL_PHISH_WHITELISTED:
1114
-		case CL_PHISH_HOST_WHITELISTED:
1115
-		case CL_PHISH_HOST_OK:
1116
-		case CL_PHISH_DOMAIN_OK:
1117
-		case CL_PHISH_REDIR_OK:
1118
-		case CL_PHISH_HOST_REDIR_OK:
1119
-		case CL_PHISH_DOMAIN_REDIR_OK:
1120
-		case CL_PHISH_HOST_REVERSE_OK:
1121
-		case CL_PHISH_DOMAIN_REVERSE_OK:
1122
-		case CL_PHISH_MAILTO_OK:
1123
-		case CL_PHISH_TEXTURL:
1124
-		case CL_PHISH_HOST_NOT_LISTED:
1125
-		case CL_PHISH_CLEAN_CID:
1126
-			return 0;
1127
-		case CL_PHISH_HEX_URL:
1128
-		case CL_PHISH_CLOAKED_NULL:
1129
-		case CL_PHISH_SSL_SPOOF:
1130
-		case CL_PHISH_CLOAKED_UIU:
1131
-		case CL_PHISH_NUMERIC_IP:
1132
-		case CL_PHISH_NOMATCH:
1133
-			return 1;
1134
-		default:
1135
-			return 1;
1136
-	}
1137
-}
1138 1108
 /* urls can't contain null pointer, caller must ensure this */
1139 1109
 static enum phish_status phishingCheck(const struct cl_engine* engine,struct url_check* urls)
1140 1110
 {
1141 1111
 	struct url_check host_url;
1142
-	enum phish_status rc=CL_PHISH_NODECISION;
1112
+	int rc = CL_PHISH_NODECISION;
1143 1113
 	int phishy=0;
1144 1114
 	const struct phishcheck* pchk = (const struct phishcheck*) engine->phishcheck;
1145 1115
 
1146
-	if(!urls->realLink.data)
1116
+	if(!urls->realLink.data || urls->displayLink.data[0]=='\0')
1147 1117
 		return CL_PHISH_CLEAN;
1148 1118
 
1149 1119
 	cli_dbgmsg("Phishcheck:Checking url %s->%s\n", urls->realLink.data,
... ...
@@ -1153,59 +1099,43 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1153 1153
 		return CL_PHISH_CLEAN;/* displayed and real URL are identical -> clean */
1154 1154
 
1155 1155
 	if((rc = cleanupURLs(urls))) {
1156
-		if(isPhishing(rc))/* not allowed to decide this is phishing */
1157
-			return CL_PHISH_CLEAN;
1158
-		return rc;/* URLs identical after cleanup */
1156
+		/* it can only return an error, or say its clean;
1157
+		 * it is not allowed to decide it is phishing */
1158
+		return rc < 0 ? rc : CL_PHISH_CLEAN;
1159 1159
 	}
1160 1160
 
1161
-	if(whitelist_check(engine,urls,0))
1162
-		return CL_PHISH_WHITELISTED;/* if url is whitelist don't perform further checks */
1161
+	if(whitelist_check(engine, urls, 0))
1162
+		return CL_PHISH_CLEAN;/* if url is whitelisted don't perform further checks */
1163 1163
 
1164
-	if((!isURL(pchk, urls->displayLink.data) || !isRealURL(pchk, urls->realLink.data) )&&
1164
+	if((!isURL(pchk, urls->displayLink.data) || !isRealURL(pchk, urls->realLink.data) ) &&
1165 1165
 			( (phishy&PHISHY_NUMERIC_IP && !isNumericURL(pchk, urls->displayLink.data)) ||
1166 1166
 			  !(phishy&PHISHY_NUMERIC_IP))) {
1167 1167
 		cli_dbgmsg("Displayed 'url' is not url:%s\n",urls->displayLink.data);
1168
-		return CL_PHISH_TEXTURL;
1168
+		return CL_PHISH_CLEAN;
1169 1169
 	}
1170 1170
 
1171
-	if(urls->flags&DOMAINLIST_REQUIRED && domainlist_match(engine,urls->realLink.data,urls->displayLink.data,NULL,0,&urls->flags))
1171
+	if(domainlist_match(engine, urls->realLink.data, urls->displayLink.data, NULL, 0, &urls->flags)) {
1172 1172
 		phishy |= DOMAIN_LISTED;
1173
-	else {
1173
+	} else {
1174 1174
 		/* although entire url is not listed, the host might be,
1175 1175
 		 * so defer phishing decisions till we know if host is listed*/
1176 1176
 	}
1177 1177
 
1178
-	
1179 1178
 	url_check_init(&host_url);
1180 1179
 
1181
-	if((rc = url_get_host(pchk, urls,&host_url,DOMAIN_DISPLAY,&phishy))) {
1180
+	if((rc = url_get_host(pchk, urls, &host_url, DOMAIN_DISPLAY, &phishy))) {
1182 1181
 		free_if_needed(&host_url);
1183
-		if(isPhishing(rc))
1184
-			return CL_PHISH_CLEAN;
1185
-		return rc;
1182
+		return rc < 0 ? rc : CL_PHISH_CLEAN;
1186 1183
 	}
1187 1184
 
1188
-
1189
-	if(urls->flags&DOMAINLIST_REQUIRED) {
1190
-		if(!(phishy&DOMAIN_LISTED)) {
1191
-			if(domainlist_match(engine,host_url.displayLink.data,host_url.realLink.data,&urls->pre_fixup,1,&urls->flags))
1192
-				phishy |= DOMAIN_LISTED;
1193
-			else {
1194
-			}
1195
-		}
1185
+	if(!(phishy&DOMAIN_LISTED) &&
1186
+		!domainlist_match(engine,host_url.displayLink.data,host_url.realLink.data,&urls->pre_fixup,1,&urls->flags)) {
1187
+			return CL_PHISH_CLEAN; /* domain not listed */
1196 1188
 	}
1197 1189
 
1198 1190
 	/* link type filtering must occur after last domainlist_match */
1199 1191
 	if(urls->link_type & LINKTYPE_IMAGE && !(urls->flags&CHECK_IMG_URL))
1200
-		return CL_PHISH_HOST_NOT_LISTED;/* its listed, but this link type is filtered */
1201
-
1202
-	if(urls->flags & DOMAINLIST_REQUIRED && !(phishy & DOMAIN_LISTED) ) {
1203
-		urls->flags &= urls->always_check_flags;
1204
-		if(!urls->flags) {
1205
-				free_if_needed(&host_url);
1206
-				return CL_PHISH_HOST_NOT_LISTED;
1207
-			}
1208
-		}
1192
+		return CL_PHISH_CLEAN;/* its listed, but this link type is filtered */
1209 1193
 
1210 1194
 	if(urls->flags&CHECK_CLOAKING) {
1211 1195
 		/*Checks if URL is cloaked.
... ...
@@ -1221,63 +1151,41 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1221 1221
 		}
1222 1222
 	}
1223 1223
 
1224
-
1225
-	if(urls->displayLink.data[0]=='\0') {
1226
-		free_if_needed(&host_url);
1227
-		return CL_PHISH_CLEAN;
1228
-	}
1229
-
1230 1224
 	if(urls->flags&CHECK_SSL && isSSL(urls->displayLink.data) && !isSSL(urls->realLink.data)) {
1231 1225
 		free_if_needed(&host_url);
1232 1226
 		return CL_PHISH_SSL_SPOOF;
1233 1227
 	}
1234 1228
 
1235
-	if(!urls->flags&CHECK_CLOAKING && urls->flags & DOMAINLIST_REQUIRED && !(phishy&DOMAIN_LISTED) ) {
1236
-		free_if_needed(&host_url);
1237
-		return CL_PHISH_HOST_NOT_LISTED;
1238
-	}
1239
-
1240 1229
 	if((rc = url_get_host(pchk, urls,&host_url,DOMAIN_REAL,&phishy)))
1241 1230
 	{
1242 1231
 		free_if_needed(&host_url);
1243
-		return rc;
1232
+		return rc < 0 ? rc : CL_PHISH_CLEAN;
1244 1233
 	}
1245 1234
 
1246
-	if(urls->flags&DOMAINLIST_REQUIRED && !(phishy&DOMAIN_LISTED)) {
1235
+	if(whitelist_check(engine,&host_url,1)) {
1247 1236
 		free_if_needed(&host_url);
1248
-		return CL_PHISH_HOST_NOT_LISTED;
1237
+		return CL_PHISH_CLEAN;
1249 1238
 	}
1250 1239
 
1251
-	if(whitelist_check(engine,&host_url,1)) {
1240
+	if(!strcmp(urls->realLink.data,urls->displayLink.data)) {
1252 1241
 		free_if_needed(&host_url);
1253
-		return CL_PHISH_HOST_WHITELISTED;
1242
+		return CL_PHISH_CLEAN;
1254 1243
 	}
1255 1244
 
1256
-
1257
-	if(urls->flags&HOST_SUFFICIENT) {
1258
-		if(!strcmp(urls->realLink.data,urls->displayLink.data)) {
1245
+	{
1246
+		struct url_check domain_url;
1247
+		url_check_init(&domain_url);
1248
+		url_get_domain(pchk, &host_url,&domain_url);
1249
+		if(!strcmp(domain_url.realLink.data,domain_url.displayLink.data)) {
1259 1250
 			free_if_needed(&host_url);
1260
-			return CL_PHISH_HOST_OK;
1261
-		}
1262
-
1263
-
1264
-		if(urls->flags&DOMAIN_SUFFICIENT) {
1265
-			struct url_check domain_url;
1266
-			url_check_init(&domain_url);
1267
-			url_get_domain(pchk, &host_url,&domain_url);
1268
-			if(!strcmp(domain_url.realLink.data,domain_url.displayLink.data)) {
1269
-				free_if_needed(&host_url);
1270
-				free_if_needed(&domain_url);
1271
-				return CL_PHISH_DOMAIN_OK;
1272
-			}
1273 1251
 			free_if_needed(&domain_url);
1252
+			return CL_PHISH_CLEAN;
1274 1253
 		}
1254
+		free_if_needed(&domain_url);
1255
+	}
1275 1256
 
1276
-		free_if_needed(&host_url);
1277
-	}/*HOST_SUFFICIENT*/
1257
+	free_if_needed(&host_url);
1278 1258
 	/*we failed to find a reason why the 2 URLs are different, this is definitely phishing*/
1279
-	if(urls->flags&DOMAINLIST_REQUIRED && !(phishy&DOMAIN_LISTED))
1280
-		return CL_PHISH_HOST_NOT_LISTED;
1281 1259
 	return phishy_map(phishy,CL_PHISH_NOMATCH);
1282 1260
 }
1283 1261
 
... ...
@@ -1286,28 +1194,6 @@ static const char* phishing_ret_toString(enum phish_status rc)
1286 1286
 	switch(rc) {
1287 1287
 		case CL_PHISH_CLEAN:
1288 1288
 			return "Clean";
1289
-		case CL_PHISH_CLEANUP_OK:
1290
-			return "URLs match after cleanup";
1291
-		case CL_PHISH_WHITELISTED:
1292
-			return "URL is whitelisted";
1293
-		case CL_PHISH_HOST_WHITELISTED:
1294
-			return "host part of URL is whitelist";
1295
-		case CL_PHISH_HOST_OK:
1296
-			return "Hosts match";
1297
-		case CL_PHISH_DOMAIN_OK:
1298
-			return "Domains match";
1299
-		case CL_PHISH_REDIR_OK:
1300
-			return "After redirecting realURL, they match";
1301
-		case CL_PHISH_HOST_REDIR_OK:
1302
-			return "After redirecting realURL, hosts match";
1303
-		case CL_PHISH_DOMAIN_REDIR_OK:
1304
-			return "After redirecting the domains match";
1305
-		case CL_PHISH_MAILTO_OK:
1306
-			return "URL is mailto";
1307
-		case CL_PHISH_NUMERIC_IP:
1308
-			return "IP address encountered in hostname";
1309
-		case CL_PHISH_TEXTURL:
1310
-			return "Displayed link is not an URL, can't check if phishing or not";
1311 1289
 		case CL_PHISH_CLOAKED_NULL:
1312 1290
 			return "Link URL is cloaked (null byte %00)";
1313 1291
 		case CL_PHISH_CLOAKED_UIU:
... ...
@@ -1317,10 +1203,6 @@ static const char* phishing_ret_toString(enum phish_status rc)
1317 1317
 			return "Visible links is SSL, real link is not";
1318 1318
 		case CL_PHISH_NOMATCH:
1319 1319
 			return "URLs are way too different";
1320
-		case CL_PHISH_HOST_NOT_LISTED:
1321
-			return "Host not listed in .pdb -> not checked";
1322
-		case CL_PHISH_CLEAN_CID:
1323
-			return "Embedded image in mail -> clean";
1324 1320
 		case CL_PHISH_HEX_URL:
1325 1321
 			return "Embedded hex urls";
1326 1322
 		default:
... ...
@@ -23,30 +23,17 @@
23 23
 #include "regex/regex.h"
24 24
 
25 25
 #define CL_PHISH_BASE 100
26
-enum phish_status {CL_PHISH_NODECISION=0,CL_PHISH_CLEAN=CL_PHISH_BASE, CL_PHISH_CLEANUP_OK,CL_PHISH_HOST_OK, CL_PHISH_DOMAIN_OK,
27
-	CL_PHISH_HOST_NOT_LISTED,
28
-	CL_PHISH_REDIR_OK, CL_PHISH_HOST_REDIR_OK, CL_PHISH_DOMAIN_REDIR_OK,
29
-	CL_PHISH_HOST_REVERSE_OK,CL_PHISH_DOMAIN_REVERSE_OK,
30
-	CL_PHISH_WHITELISTED,CL_PHISH_HOST_WHITELISTED,
31
-	CL_PHISH_CLEAN_CID,
32
-	CL_PHISH_TEXTURL, CL_PHISH_MAILTO_OK,
33
-	CL_PHISH_CLOAKED_UIU, CL_PHISH_NUMERIC_IP,CL_PHISH_HEX_URL,CL_PHISH_CLOAKED_NULL,CL_PHISH_SSL_SPOOF, CL_PHISH_NOMATCH};
34
-
35
-#define HOST_SUFFICIENT   1
36
-#define DOMAIN_SUFFICIENT (HOST_SUFFICIENT | 2)
37
-#define DO_REVERSE_LOOKUP 4
38
-#define CHECK_REDIR       8
39
-#define CHECK_SSL         16
40
-#define CHECK_CLOAKING    32
41
-#define CLEANUP_URL       64
42
-#define CHECK_DOMAIN_REVERSE 128
43
-#define CHECK_IMG_URL        256
44
-#define DOMAINLIST_REQUIRED  512
45
-/* img checking disabled by default */
26
+enum phish_status {CL_PHISH_NODECISION=0, CL_PHISH_CLEAN=CL_PHISH_BASE,
27
+	CL_PHISH_CLOAKED_UIU, CL_PHISH_NUMERIC_IP, CL_PHISH_HEX_URL, CL_PHISH_CLOAKED_NULL, CL_PHISH_SSL_SPOOF, CL_PHISH_NOMATCH};
28
+
29
+#define CHECK_SSL         1
30
+#define CHECK_CLOAKING    2
31
+#define CLEANUP_URL       4
32
+#define CHECK_IMG_URL     8
46 33
 
47 34
 #define LINKTYPE_IMAGE     1
48 35
 
49
-#define CL_PHISH_ALL_CHECKS (CLEANUP_URL|DOMAIN_SUFFICIENT|CHECK_SSL|CHECK_CLOAKING|CHECK_IMG_URL)
36
+#define CL_PHISH_ALL_CHECKS (CLEANUP_URL|CHECK_SSL|CHECK_CLOAKING|CHECK_IMG_URL)
50 37
 
51 38
 struct string {
52 39
 	int refcount;
... ...
@@ -1,6 +1,7 @@
1 1
 /*
2
- *  Copyright (C) 2006 Sensory Networks, Inc.
3
- *             Written by aCaB <acab@clamav.net>
2
+ *  Copyright (C) 2007 Sourcefire Inc.
3
+ *  Author: aCaB <acab@clamav.net>
4
+ *
4 5
  *  This program is free software; you can redistribute it and/or modify
5 6
  *  it under the terms of the GNU General Public License version 2 as
6 7
  *  published by the Free Software Foundation.
... ...
@@ -16,346 +17,218 @@
16 16
  *  MA 02110-1301, USA.
17 17
  */
18 18
 
19
-/*
20
-** wwunpack.c
21
-**
22
-** 09/07/2k6 - Campioni del mondo!!!
23
-** 14/07/2k6 - RCE'ed + standalone sect unpacker
24
-** 15/07/2k6 - Merge started
25
-** 17/07/2k6 - Rebuild
26
-** 18/07/2k6 - Secured (well, hopefully...)
27
-**
28
-*/
29
-
30
-/*
31
-** Unpacks+rebuilds WWPack32 1.20
32
-**
33
-** Just boooooring stuff, blah.
34
-**
35
-*/
36
-
37
-
38
-/*
39
-** TODO:
40
-**
41
-** review
42
-** check eax vs al
43
-** (check for dll's)
44
-** (have a look at older versions)
45
-**
46
-*/
47
-
48
-
49 19
 #if HAVE_CONFIG_H
50 20
 #include "clamav-config.h"
51 21
 #endif
52 22
 
53
-#include <stdlib.h>
54
-#include <string.h>
55
-
56 23
 #include "cltypes.h"
57 24
 #include "others.h"
58
-#include "wwunpack.h"
59
-
60
-#define VAALIGN(s) (((s)/0x1000+((s)%0x1000!=0))*0x1000)
61
-#define FIXVS(v, r) (VAALIGN((r>v)?r:v))
25
+#include "execs.h"
62 26
 
27
+#if HAVE_STRING_H
28
+#include <string.h>
29
+#endif
63 30
 
64
-static int getbitmap(uint32_t *bitmap, char **src, uint8_t *bits, char *buf, unsigned int size) {
65
-  if (! CLI_ISCONTAINED(buf, size, *src, 4)) return 1;
66
-  *bitmap=cli_readint32(*src);
67
-  *src+=4;
68
-  *bits=32;
69
-  return 0;
31
+#define RESEED \
32
+if (CLI_ISCONTAINED(compd, szd, ccur, 4)) { \
33
+  bt = cli_readint32(ccur); \
34
+  ccur+=4; \
35
+} else { \
36
+  cli_dbgmsg("WWPack: Out of bits\n"); \
37
+  error=1; \
38
+} \
39
+bc = 32;
40
+
41
+
42
+#define BIT \
43
+bits = bt>>31; \
44
+bt<<=1; \
45
+if(!--bc) { \
46
+  RESEED; \
70 47
 }
71 48
 
72
-static int getbits(uint8_t X, uint32_t *eax, uint32_t *bitmap, uint8_t *bits, char **src, char *buf, unsigned int size) {
73
-  *eax=*bitmap>>(32-X);
74
-  if (*bits>X) {
75
-    *bitmap<<=X;
76
-    *bits-=X;
77
-  } else if (*bits<X) {
78
-    X-=*bits;
79
-    *eax>>=X;
80
-    if (getbitmap(bitmap, src, bits, buf, size)) return 1;
81
-    *eax<<=X;
82
-    *eax|=*bitmap>>(32-X);
83
-    *bitmap<<=X;
84
-    *bits-=X;
85
-  } else {
86
-    if (getbitmap(bitmap, src, bits, buf, size)) return 1;
87
-  }
88
-  return 0;
49
+#define BITS(N) \
50
+bits = bt>>(32-(N)); \
51
+if (bc>=(N)) { \
52
+  bc -= (N); \
53
+  bt<<=(N); \
54
+  if (!bc) { \
55
+    RESEED; \
56
+  } \
57
+} else { \
58
+  if (CLI_ISCONTAINED(compd, szd, ccur, 4)) { \
59
+    bt = cli_readint32(ccur); \
60
+    ccur+=4; \
61
+    bc += 32 - (N); \
62
+    bits |= bt>>(bc); \
63
+    bt <<= (32-bc); \
64
+  } else { \
65
+    cli_dbgmsg("WWPack: Out of bits\n"); \
66
+    error=1; \
67
+  } \
89 68
 }
90 69
 
91
-static int wunpsect(char *packed, char *unpacked, unsigned int psize, unsigned int usize) {
92
-  char *src=packed, *dst=unpacked;
93
-  uint32_t bitmap, eax;
94
-  uint8_t bits;
95
-  unsigned int lostbit, getmorestuff;
96
-  uint16_t backbytes;
97
-  uint16_t backsize;
98
-  uint8_t oal;
99
-
100
-  if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1;
101
-  eax=bitmap;
70
+int wwunpack(uint8_t *exe, uint32_t exesz, uint8_t *wwsect, struct cli_exe_section *sects, uint16_t scount, uint32_t pe, int desc) {
71
+  uint8_t *structs = wwsect + 0x2a1, *compd, *ccur, *unpd, *ucur, bc;
72
+  uint32_t src, srcend, szd, bt, bits;
73
+  int error=0, i;
102 74
 
75
+  cli_dbgmsg("in wwunpack\n");
103 76
   while (1) {
104
-    lostbit=bitmap>>31;
105
-    bitmap<<=1;
106
-    bits--;
107
-    if (!lostbit && bits) {
108
-      if (!(CLI_ISCONTAINED(packed, psize, src, 1) && CLI_ISCONTAINED(unpacked, usize, dst, 1))) return 1;
109
-      *dst++=*src++;
110
-      continue;
77
+    if (!CLI_ISCONTAINED(wwsect, sects[scount].rsz, structs, 17)) {
78
+      cli_dbgmsg("WWPack: Array of structs out of section\n");
79
+      break;
111 80
     }
112
-    
113
-    if (!bits) {
114
-      if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1;
115
-      eax=bitmap;
116
-      if (!lostbit) {
117
-	if (!(CLI_ISCONTAINED(packed, psize, src, 1) && CLI_ISCONTAINED(unpacked, usize, dst, 1))) return 1;
118
-	*dst++=*src++;
119
-	continue;
120
-      }
81
+    src = sects[scount].rva - cli_readint32(structs); /* src delta / dst delta - not used / dwords / end of src */
82
+    structs+=8;
83
+    szd = cli_readint32(structs) * 4;
84
+    structs+=4;
85
+    srcend = cli_readint32(structs);
86
+    structs+=4;
87
+
88
+    unpd = ucur = exe+src+srcend+4-szd;
89
+    if (!szd || !CLI_ISCONTAINED(exe, exesz, unpd, szd)) {
90
+      cli_dbgmsg("WWPack: Compressed data out of file\n");
91
+      break;
121 92
     }
93
+    cli_dbgmsg("WWP: src: %x, szd: %x, srcend: %x - %x\n", src, szd, srcend, srcend+4-szd);
94
+    if (!(compd = cli_malloc(szd))) break;
95
+    memcpy(compd, unpd, szd);
96
+    memset(unpd, -1, szd); /*FIXME*/
97
+    ccur=compd;
122 98
     
123
-    if (getbits(2, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
124
-    
125
-    if ((eax&0xff)>=3) {
126
-      /* 50ff - two_bytes */
127
-      uint8_t fetchbits;
128
-      
129
-      if (getbits(2, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
130
-      fetchbits=(eax&0xff)+5;
131
-      eax--;
132
-      if ((int16_t)(eax&0xffff)<=0) {
133
-	/* 5113 */
134
-	backbytes=1<<fetchbits;
135
-	backbytes=(backbytes&0xff00)|((backbytes-31)&0xff);
136
-      } else {
137
-	/* 511b */
138
-	fetchbits++;
139
-	backbytes=1<<fetchbits;
140
-	backbytes-=0x9f;
99
+    RESEED;
100
+    while(!error) {
101
+      uint32_t backbytes, backsize;
102
+      uint8_t saved;
103
+
104
+      BIT;
105
+      if (!bits) { /* BYTE copy */
106
+	if(ccur-compd>=szd || !CLI_ISCONTAINED(exe, exesz, ucur, 1))
107
+	  error=1;
108
+	else
109
+	  *ucur++=*ccur++;
110
+	continue;
141 111
       }
142
-      /* 5125 */
143
-      if (getbits(fetchbits, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
144
-      if ((eax&0xffff)==0x1ff) break;
145
-      eax&=0xffff;
146
-      backbytes+=eax;
147
-      if (!(CLI_ISCONTAINED(unpacked, usize, dst-backbytes, 2) && CLI_ISCONTAINED(unpacked, usize, dst, 2))) return 1;
148
-      *dst=*(dst-backbytes);
149
-      dst++;
150
-      *dst=*(dst-backbytes);
151
-      dst++;
152
-      continue;
153
-    }
154 112
 
155
-    /* 5143 - more_backbytes */      
156
-    oal=eax&0xff;
157
-    getmorestuff=1;
158
-
159
-    
160
-    if (getbits(3, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
161
-    if ((eax&0xff)<=3) {
162
-      lostbit=0;
163
-      if ((eax&0xff)==3) {
164
-	/* next_bit_or_reseed */
165
-	lostbit=bitmap>>31;
166
-	bitmap<<=1;
167
-	bits--;
168
-	if (!bits) {
169
-	  if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1; 
113
+      BITS(2);
114
+      if(bits==3) { /* WORD backcopy */
115
+	uint8_t shifted, subbed = 31;
116
+	BITS(2);
117
+	shifted = bits + 5;
118
+	if(bits>=2) {
119
+	  shifted++;
120
+	  subbed += 0x80;
170 121
 	}
171
-      }
172
-      eax=eax+lostbit+5;
173
-      /* jmp more_bb_commondock */
174
-    } else { /* >3 */
175
-      /* 5160 - more_bb_morethan3 */
176
-      if ((eax&0xff)==4) {
177
-	/* next_bit_or_reseed */
178
-	lostbit=bitmap>>31;
179
-	bitmap<<=1;
180
-	bits--;
181
-	if (!bits) {
182
-	  if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1;  
122
+	backbytes = (1<<shifted)-subbed; /* 1h, 21h, 61h, 161h */
123
+	BITS(shifted); /* 5, 6, 8, 9 */
124
+	if(error || bits == 0x1ff) break;
125
+	backbytes+=bits;
126
+	if(!CLI_ISCONTAINED(exe, exesz, ucur, 2) || !CLI_ISCONTAINED(exe, exesz, ucur-backbytes, 2)) {
127
+	  error=1;
128
+	} else {
129
+	  ucur[0]=*(ucur-backbytes);
130
+	  ucur[1]=*(ucur-backbytes+1);
131
+	  ucur+=2;
183 132
 	}
184
-	eax=eax+lostbit+6;
185
-	/* jmp more_bb_commondock */
186
-      } else { /* !=4 */
187
-	eax+=7;
188
-	if ((eax&0xff)>=0x0d) {
189
-	  getmorestuff=0; /* jmp more_bb_PASTcommondock */
190
-	  if ((eax&0xff)==0x0d) {
191
-	    /* 5179  */
192
-	    if (getbits(0x0e, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
193
-	    eax+=0x1fe1;
194
-	  } else {
195
-	    /* 516c */
196
-	    if (getbits(0x0f, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
197
-	    eax+=0x5fe1;
198
-	  }
199
-	  /* jmp more_bb_PASTcommondock */
200
-	} /* al >= 0d */
201
-      } /* al != 4 */
202
-    } /* >3 */
203
-    
204
-    if (getmorestuff) {
205
-      /* 5192 - more_bb_commondock */
206
-      uint16_t bk=(1<<(eax&0xff))-0x1f;
207
-      if (getbits((eax&0xff), &eax, &bitmap, &bits, &src, packed, psize)) return 1;
208
-      eax+=bk;
209
-    }
210
-    
211
-    /* 51a7 - more_bb_pastcommondock */
212
-    eax&=0xffff;
213
-    backbytes=eax;
214
-    backsize=3+(oal!=1);
215
-    
216
-    if (oal<1) { /* overrides backsize */
217
-      /* 51bb - more_bb_again */
218
-      
219
-      /* next_bit_or_reseed */
220
-      lostbit=bitmap>>31;
221
-      bitmap<<=1;
222
-      bits--;
223
-      if (!bits) {
224
-	if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1;  
133
+	continue;
225 134
       }
226
-      if (!lostbit) {
227
-	/* 51c2 */
228
-	/* next_bit_or_reseed */
229
-	lostbit=bitmap>>31;
230
-	bitmap<<=1;
231
-	bits--;
232
-	if (!bits) {
233
-	  if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1;   
135
+
136
+      /* BLOCK backcopy */
137
+      saved = bits; /* cmp al, 1 / pushf */
138
+
139
+      BITS(3);
140
+      if (bits<6) {
141
+	backbytes = bits;
142
+	switch(bits) {
143
+	case 4: /* 10,11 */
144
+	  backbytes++;
145
+	case 3: /* 8,9 */
146
+	  BIT;
147
+	  backbytes+=bits;
148
+	case 0:	case 1:	case 2: /* 5,6,7 */
149
+	  backbytes+=5;
150
+	  break;
151
+	case 5: /* 12 */
152
+	  backbytes=12;
153
+	  break;
234 154
 	}
235
-	eax=5+lostbit;
236
-	/* jmp setsize_and_backcopy */
155
+	BITS(backbytes);
156
+	bits+=(1<<backbytes)-31;
157
+      } else if(bits==6) {
158
+	BITS(0x0e);
159
+	bits+=0x1fe1;
237 160
       } else {
238
-	/* 51ce - more_bb_again_and_again */
239
-	if (getbits(3, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
240
-	if (eax&0xff) {
241
-	  /* 51e6 */
242
-	  eax+=6;
243
-	  /* jmp setsize_and_backcopy */
244
-	} else {
245
-	  if (getbits(4, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
246
-	  if (eax&0xff) {
247
-	    /* 51e4 */
248
-	    eax+=7+6;
249
-	    /* jmp setsize_and_backcopy */
250
-	  } else {
251
-	    /* 51ea - OMGWTF */
252
-	    uint8_t c=4;
253
-	    uint16_t d=0x0d;
254
-	    
255
-	    while ( 1 ) {
256
-	      if (c!=7){
257
-		d+=2;
258
-		d<<=1;
259
-		d--;
260
-		
261
-		/* next_bit_or_reseed */
262
-		lostbit=bitmap>>31;
263
-		bitmap<<=1;
264
-		bits--;
265
-		if (!bits) {
266
-		  if (getbitmap(&bitmap, &src, &bits, packed, psize)) return 1;    
267
-		}
268
-		c++;
269
-		if (!lostbit) continue;
270
-		if (getbits(c, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
271
-		d+=eax&0xff;
272
-		eax&=0xffffff00;
273
-		eax|=d&0xff;
274
-	      } else {
275
-		if (getbits(14, &eax, &bitmap, &bits, &src, packed, psize)) return 1;
276
-	      }
277
-	      break;
278
-	    } /* while */
279
-	  } /* OMGWTF */
280
-	} /* eax&0xff */
281
-      } /* lostbit */
282
-	/* 521b - setsize_and_backcopy */
283
-      backsize=eax&0xffff;
284
-    }
285
-
286
-    /* 521e - backcopy */
287
-    if (!(CLI_ISCONTAINED(unpacked, usize, dst-backbytes, backsize) && CLI_ISCONTAINED(unpacked, usize, dst, backsize))) return 1;
288
-    while(backsize--){
289
-      *dst=*(dst-backbytes);
290
-      dst++;
291
-    }
292
-
293
-  } /* while true */
294
-
295
-  return 0;
296
-}
297
-
298
-int wwunpack(char *exe, uint32_t exesz, uint32_t headsize, uint32_t min, uint32_t wwprva, uint32_t e_lfanew, char *wwp, uint32_t wwpsz, uint16_t sects) {
299
-  char *stuff=wwp+0x2a1, *packed, *unpacked;
300
-  uint32_t rva, csize;
161
+	BITS(0x0f);
162
+	bits+=0x5fe1;
163
+      }
301 164
 
302
-  cli_dbgmsg("in wwunpack\n");
165
+      backbytes = bits;
303 166
 
167
+      /* popf / jb */
168
+      if (!saved) {
169
+	BIT;
170
+	if(!bits) {
171
+	  BIT;
172
+	  bits+=5;
173
+	} else {
174
+	  BITS(3);
175
+	  if(bits) {
176
+	    bits+=6;
177
+	  } else {
178
+	    BITS(4);
179
+	    if(bits) {
180
+	      bits+=13;
181
+	    } else {
182
+	      uint8_t cnt = 4;
183
+	      uint16_t shifted = 0x0d;
184
+	      
185
+	      do {
186
+		if(cnt==7) { cnt = 0x0e; shifted = 0; break; }
187
+		shifted=((shifted+2)<<1)-1;
188
+		BIT;
189
+		cnt++;
190
+	      } while(!bits);
191
+	      BITS(cnt);
192
+	      bits+=shifted;
193
+	    }
194
+	  }
195
+	}
196
+	backsize = bits;
197
+      } else {
198
+	backsize = saved+2;
199
+      }
304 200
 
305
-  while(1) {
306
-    if (!CLI_ISCONTAINED(wwp, wwpsz, stuff, 17)) {
307
-      cli_dbgmsg("WWPack: next chunk out ouf file, giving up.\n");
308
-      return 1;
309
-    }
310
-    if ((csize=cli_readint32(stuff+8)*4)!=(uint32_t)cli_readint32(stuff+12)+4) {
311
-      cli_dbgmsg("WWPack: inconsistent/hacked data, go figure!\n");
312
-      return 1;
313
-    }
314
-    rva = wwprva-cli_readint32(stuff);
315
-    if((packed = (char *) cli_calloc(csize, sizeof(char))) == NULL) {
316
-      cli_dbgmsg("WWPack: Can't allocate %d bytes\n", csize);
317
-      return 1;
318
-    }
319
-    unpacked=exe+headsize+rva-min;
320
-    if (!CLI_ISCONTAINED(exe, exesz, unpacked, csize)) {
321
-      free(packed);
322
-      cli_dbgmsg("WWPack: packed data out of bounds, giving up.\n");
323
-      return 1;
201
+      if(!CLI_ISCONTAINED(exe, exesz, ucur, backsize) || !CLI_ISCONTAINED(exe, exesz, ucur-backbytes, backsize)) error=1;
202
+      while(backsize--) {
203
+	*ucur=*(ucur-backbytes);
204
+	ucur++;
205
+      }
324 206
     }
325
-    memcpy(packed, unpacked, csize);
326
-    if (wunpsect(packed, unpacked, csize, exesz-(unpacked-exe))) {
327
-      free(packed);
328
-      cli_dbgmsg("WWPack: unpacking failed.\n");
329
-      return 1;
207
+    free(compd);
208
+    if(error) {
209
+      cli_dbgmsg("WWPack: decompression error\n");
210
+      break;
330 211
     }
331
-    free(packed);
332
-    if (!stuff[16]) break;
333
-    stuff+=17;
212
+    if (error || !*structs++) break;
334 213
   }
335 214
 
336
-  stuff=exe+e_lfanew;
337
-  stuff[6]=sects&0xff;
338
-  stuff[7]=sects>>8;
339
-
340
-  csize=cli_readint32(wwp+0x295)+wwprva+0x299;
341
-  cli_dbgmsg("WWPack: found OEP @%x\n", csize);
342
-  cli_writeint32(stuff+0x28, csize);
343
-
344
-  csize=cli_readint32(stuff+0x50)-VAALIGN(wwpsz);
345
-  cli_writeint32(stuff+0x50, csize);
346
-
347
-
348
-  stuff+=0x18+(cli_readint32(stuff+0x14)&0xffff);
349
-  while (sects--) {
350
-    uint32_t v=cli_readint32(stuff+8);
351
-    uint32_t r=cli_readint32(stuff+16);
352
-    csize=FIXVS(v, r);
353
-    cli_writeint32(stuff+8, csize);
354
-    cli_writeint32(stuff+16, csize);
355
-    cli_writeint32(stuff+20, cli_readint32(stuff+12)-min+headsize);
356
-    stuff+=0x28;
215
+  if(!error) {
216
+    exe[pe+6]=(uint8_t)scount;
217
+    exe[pe+7]=(uint8_t)(scount>>8);
218
+    cli_writeint32(&exe[pe+0x28], cli_readint32(wwsect+0x295)+sects[scount].rva+0x299);
219
+    cli_writeint32(&exe[pe+0x50], cli_readint32(&exe[pe+0x50])-sects[scount].vsz);
220
+
221
+    structs = &exe[0xffff&cli_readint32(&exe[pe+0x14])+pe+0x18];
222
+    for(i=0 ; i<scount ; i++) {
223
+      cli_writeint32(structs+8, sects[i].vsz);
224
+      cli_writeint32(structs+12, sects[i].rva);
225
+      cli_writeint32(structs+16, sects[i].vsz);
226
+      cli_writeint32(structs+20, sects[i].rva);
227
+      structs+=0x28;
228
+    }
229
+    memset(structs, 0, 0x28);
230
+    error = cli_writen(desc, exe, exesz)!=exesz;
357 231
   }
358
-  memset(stuff, 0, 0x28);
359
-
360
-  return 0;
232
+  return error;
361 233
 }
... ...
@@ -20,8 +20,8 @@
20 20
 #define __WWP32_H
21 21
 
22 22
 #include "cltypes.h"
23
-#include "rebuildpe.h"
23
+#include "execs.h"
24 24
 
25
-int wwunpack(char *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, char *, uint32_t, uint16_t);
25
+int wwunpack(uint8_t *, uint32_t, uint8_t *, struct cli_exe_section *, uint16_t, uint32_t, int);
26 26
 
27 27
 #endif