Browse code

Distcheck fixes.

Török Edvin authored on 2009/12/12 03:43:58
Showing 12 changed files
... ...
@@ -130,10 +130,11 @@ int main(int argc, char *argv[])
130 130
 	exit(1);
131 131
     }
132 132
     if(optget(opts, "version")->enabled) {
133
-	char* argvx[] = {argv[0], "--version",NULL};
133
+	char versions[] = "--version";
134
+	char* argvx[] = {argv[0], versions,NULL};
134 135
 	printf("Clam AntiVirus Bytecode Testing Tool %s\n", get_version());
135 136
 	cl_init(CL_INIT_DEFAULT);
136
-	cli_bytecode_debug(2, argvx);
137
+	cli_bytecode_printversion();
137 138
 	optfree(opts);
138 139
 	exit(0);
139 140
     }
... ...
@@ -181,6 +181,7 @@ libclamav_la_SOURCES = \
181 181
 	pe_icons.h \
182 182
 	disasm.c \
183 183
 	disasm.h \
184
+	disasm-common.h \
184 185
 	disasmpriv.h \
185 186
 	upx.c \
186 187
 	upx.h \
... ...
@@ -119,28 +119,29 @@ am__libclamav_la_SOURCES_DIST = clamav.h matcher-ac.c matcher-ac.h \
119 119
 	mbox.h message.c message.h table.c table.h text.c text.h \
120 120
 	ole2_extract.c ole2_extract.h vba_extract.c vba_extract.h \
121 121
 	cltypes.h msexpand.c msexpand.h pe.c pe.h pe_icons.c \
122
-	pe_icons.h disasm.c disasm.h disasmpriv.h upx.c upx.h \
123
-	htmlnorm.c htmlnorm.h chmunpack.c chmunpack.h rebuildpe.c \
124
-	rebuildpe.h petite.c petite.h wwunpack.c wwunpack.h unsp.c \
125
-	unsp.h aspack.c aspack.h packlibs.c packlibs.h fsg.c fsg.h \
126
-	mew.c mew.h upack.c upack.h line.c line.h untar.c untar.h \
127
-	unzip.c unzip.h inflate64.c inflate64.h inffixed64.h \
128
-	inflate64_priv.h special.c special.h binhex.c binhex.h \
129
-	is_tar.c is_tar.h tnef.c tnef.h autoit.c autoit.h unarj.c \
130
-	unarj.h nsis/bzlib.c nsis/bzlib_private.h nsis/nsis_bzlib.h \
131
-	nsis/nulsft.c nsis/nulsft.h nsis/infblock.c nsis/nsis_zconf.h \
132
-	nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c pdf.h spin.c spin.h \
133
-	yc.c yc.h elf.c elf.h execs.h sis.c sis.h uuencode.c \
134
-	uuencode.h phishcheck.c phishcheck.h phish_domaincheck_db.c \
135
-	phish_domaincheck_db.h phish_whitelist.c phish_whitelist.h \
136
-	iana_cctld.h iana_tld.h regex_list.c regex_list.h \
137
-	regex_suffix.c regex_suffix.h mspack.c mspack.h cab.c cab.h \
138
-	entconv.c entconv.h entitylist.h encoding_aliases.h hashtab.c \
139
-	hashtab.h dconf.c dconf.h 7z/LzmaDec.c 7z/LzmaDec.h 7z/Types.h \
140
-	lzma_iface.c lzma_iface.h 7z.c 7z.h 7z/7zFile.c 7z/7zFile.h \
141
-	7z/7zStream.c 7z/CpuArch.h 7z/7zCrc.c 7z/7zCrc.h 7z/7zBuf.c \
142
-	7z/7zBuf.h 7z/Bcj2.c 7z/Bcj2.h 7z/Bra.c 7z/Bra.h 7z/Bra86.c \
143
-	7z/BraIA64.c 7z/Archive/7z/7zIn.c 7z/Archive/7z/7zIn.h \
122
+	pe_icons.h disasm.c disasm.h disasm-common.h disasmpriv.h \
123
+	upx.c upx.h htmlnorm.c htmlnorm.h chmunpack.c chmunpack.h \
124
+	rebuildpe.c rebuildpe.h petite.c petite.h wwunpack.c \
125
+	wwunpack.h unsp.c unsp.h aspack.c aspack.h packlibs.c \
126
+	packlibs.h fsg.c fsg.h mew.c mew.h upack.c upack.h line.c \
127
+	line.h untar.c untar.h unzip.c unzip.h inflate64.c inflate64.h \
128
+	inffixed64.h inflate64_priv.h special.c special.h binhex.c \
129
+	binhex.h is_tar.c is_tar.h tnef.c tnef.h autoit.c autoit.h \
130
+	unarj.c unarj.h nsis/bzlib.c nsis/bzlib_private.h \
131
+	nsis/nsis_bzlib.h nsis/nulsft.c nsis/nulsft.h nsis/infblock.c \
132
+	nsis/nsis_zconf.h nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c \
133
+	pdf.h spin.c spin.h yc.c yc.h elf.c elf.h execs.h sis.c sis.h \
134
+	uuencode.c uuencode.h phishcheck.c phishcheck.h \
135
+	phish_domaincheck_db.c phish_domaincheck_db.h \
136
+	phish_whitelist.c phish_whitelist.h iana_cctld.h iana_tld.h \
137
+	regex_list.c regex_list.h regex_suffix.c regex_suffix.h \
138
+	mspack.c mspack.h cab.c cab.h entconv.c entconv.h entitylist.h \
139
+	encoding_aliases.h hashtab.c hashtab.h dconf.c dconf.h \
140
+	7z/LzmaDec.c 7z/LzmaDec.h 7z/Types.h lzma_iface.c lzma_iface.h \
141
+	7z.c 7z.h 7z/7zFile.c 7z/7zFile.h 7z/7zStream.c 7z/CpuArch.h \
142
+	7z/7zCrc.c 7z/7zCrc.h 7z/7zBuf.c 7z/7zBuf.h 7z/Bcj2.c \
143
+	7z/Bcj2.h 7z/Bra.c 7z/Bra.h 7z/Bra86.c 7z/BraIA64.c \
144
+	7z/Archive/7z/7zIn.c 7z/Archive/7z/7zIn.h \
144 145
 	7z/Archive/7z/7zDecode.c 7z/Archive/7z/7zDecode.h \
145 146
 	7z/Archive/7z/7zItem.c 7z/Archive/7z/7zItem.h \
146 147
 	7z/Archive/7z/7zHeader.c 7z/Archive/7z/7zHeader.h \
... ...
@@ -614,15 +615,15 @@ libclamav_la_SOURCES = clamav.h matcher-ac.c matcher-ac.h matcher-bm.c \
614 614
 	rtf.c rtf.h blob.c blob.h mbox.c mbox.h message.c message.h \
615 615
 	table.c table.h text.c text.h ole2_extract.c ole2_extract.h \
616 616
 	vba_extract.c vba_extract.h cltypes.h msexpand.c msexpand.h \
617
-	pe.c pe.h pe_icons.c pe_icons.h disasm.c disasm.h disasmpriv.h \
618
-	upx.c upx.h htmlnorm.c htmlnorm.h chmunpack.c chmunpack.h \
619
-	rebuildpe.c rebuildpe.h petite.c petite.h wwunpack.c \
620
-	wwunpack.h unsp.c unsp.h aspack.c aspack.h packlibs.c \
621
-	packlibs.h fsg.c fsg.h mew.c mew.h upack.c upack.h line.c \
622
-	line.h untar.c untar.h unzip.c unzip.h inflate64.c inflate64.h \
623
-	inffixed64.h inflate64_priv.h special.c special.h binhex.c \
624
-	binhex.h is_tar.c is_tar.h tnef.c tnef.h autoit.c autoit.h \
625
-	unarj.c unarj.h nsis/bzlib.c nsis/bzlib_private.h \
617
+	pe.c pe.h pe_icons.c pe_icons.h disasm.c disasm.h \
618
+	disasm-common.h disasmpriv.h upx.c upx.h htmlnorm.c htmlnorm.h \
619
+	chmunpack.c chmunpack.h rebuildpe.c rebuildpe.h petite.c \
620
+	petite.h wwunpack.c wwunpack.h unsp.c unsp.h aspack.c aspack.h \
621
+	packlibs.c packlibs.h fsg.c fsg.h mew.c mew.h upack.c upack.h \
622
+	line.c line.h untar.c untar.h unzip.c unzip.h inflate64.c \
623
+	inflate64.h inffixed64.h inflate64_priv.h special.c special.h \
624
+	binhex.c binhex.h is_tar.c is_tar.h tnef.c tnef.h autoit.c \
625
+	autoit.h unarj.c unarj.h nsis/bzlib.c nsis/bzlib_private.h \
626 626
 	nsis/nsis_bzlib.h nsis/nulsft.c nsis/nulsft.h nsis/infblock.c \
627 627
 	nsis/nsis_zconf.h nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c \
628 628
 	pdf.h spin.c spin.h yc.c yc.h elf.c elf.h execs.h sis.c sis.h \
... ...
@@ -30,6 +30,7 @@
30 30
 #include "bytecode.h"
31 31
 #include "bytecode_priv.h"
32 32
 #include "readdb.h"
33
+#include "scanners.h"
33 34
 #include <string.h>
34 35
 
35 36
 /* TODO: we should make sure lsigcnt is never NULL, and has at least as many
... ...
@@ -82,7 +83,7 @@ int cli_bytecode_context_getresult_file(struct cli_bc_ctx *ctx, char **tempfilen
82 82
 }
83 83
 
84 84
 /* resets bytecode state, so you can run another bytecode with same ctx */
85
-int cli_bytecode_context_reset(struct cli_bc_ctx *ctx)
85
+static int cli_bytecode_context_reset(struct cli_bc_ctx *ctx)
86 86
 {
87 87
     free(ctx->opsizes);
88 88
     free(ctx->values);
... ...
@@ -94,7 +95,8 @@ int cli_bytecode_context_reset(struct cli_bc_ctx *ctx)
94 94
     if (ctx->outfd != -1) {
95 95
 	cli_dbgmsg("Bytecode: nobody cared about FD %d, %s\n", ctx->outfd,
96 96
 		   ctx->tempfile);
97
-	ftruncate(ctx->outfd, 0);
97
+	if (ftruncate(ctx->outfd, 0) == -1)
98
+	    cli_dbgmsg("ftruncate failed\n");
98 99
 	close(ctx->outfd);
99 100
 	cli_unlink(ctx->tempfile);
100 101
 	free(ctx->tempfile);
... ...
@@ -1579,7 +1581,6 @@ int cli_bytecode_done(struct cli_all_bc *allbc)
1579 1579
 
1580 1580
 int cli_bytecode_context_setfile(struct cli_bc_ctx *ctx, fmap_t *map)
1581 1581
 {
1582
-    struct stat buf;
1583 1582
     ctx->fmap = map;
1584 1583
     ctx->file_size = map->len + map->offset;
1585 1584
     return 0;
... ...
@@ -1654,7 +1655,8 @@ int cli_bytecode_runhook(const struct cl_engine *engine, struct cli_bc_ctx *ctx,
1654 1654
 		cli_dbgmsg("***** Scanning unpacked file ******\n");
1655 1655
 		ret = cli_magic_scandesc(fd, cctx);
1656 1656
 		if (!cctx || !cctx->engine->keeptmp)
1657
-		    ftruncate(fd, 0);
1657
+		    if (ftruncate(fd, 0) == -1)
1658
+			cli_dbgmsg("ftruncate failed\n");
1658 1659
 		close(fd);
1659 1660
 		if (!cctx || !cctx->engine->keeptmp) {
1660 1661
 		    if (cli_unlink(tempfile))
... ...
@@ -110,6 +110,7 @@ extern "C" {
110 110
 int bytecode_init(void);
111 111
 /* Bytecode internal debug API */
112 112
 void cli_bytecode_debug(int argc, char **argv);
113
+void cli_bytecode_printversion();
113 114
 void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx);
114 115
 
115 116
 typedef void (*bc_dbg_callback_trace)(struct cli_bc_ctx*, unsigned event);
... ...
@@ -97,6 +97,7 @@ uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx* ctx, const uint8_t *name, uin
97 97
 uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT *res, uint32_t len)
98 98
 {
99 99
     //TODO: call disasm_x86_wrap, which outputs a MARIO struct
100
+    return -1;
100 101
 }
101 102
 
102 103
 /* TODO: field in ctx, id of last bytecode that called magicscandesc, reset
... ...
@@ -129,7 +130,7 @@ int32_t cli_bcapi_write(struct cli_bc_ctx *ctx, uint8_t*data, int32_t len)
129 129
     res = cli_writen(ctx->outfd, data, len);
130 130
     if (res > 0) ctx->written += res;
131 131
     if (res == -1)
132
-	    cli_dbgmsg("Bytecode API: write failed: %s\n", errno);
132
+	    cli_dbgmsg("Bytecode API: write failed: %d\n", errno);
133 133
     return res;
134 134
 }
135 135
 
... ...
@@ -20,6 +20,7 @@
20 20
  *  MA 02110-1301, USA.
21 21
  */
22 22
 
23
+#include <stdio.h>
23 24
 #include <stdlib.h>
24 25
 #include "cltypes.h"
25 26
 #include "bytecode.h"
... ...
@@ -69,4 +70,7 @@ int bytecode_init(void)
69 69
 void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) {
70 70
     // Empty
71 71
 }
72
+void cli_bytecode_printversion() {
73
+  printf("LLVM not compiled in\n");
74
+}
72 75
 int have_clamjit=0;
... ...
@@ -830,7 +830,8 @@ distclean-local:
830 830
 	rm -f llvm/mklib llvm/tools/Makefile llvm/tools/llvmc/llvm-config.in llvm/utils/Makefile
831 831
 	rm -f llvm/Makefile.common llvm/Makefile.config llvm/config.log llvm/unittests/Makefile
832 832
 	rm -f llvm/llvm.spec llvm/include/llvm/Config/AsmPrinters.def llvm/include/llvm/Config/config.h
833
-	rm -f llvm/include/llvm/Support/DataTypes.h llvm/include/llvm/Config/Targets.def
833
+	rm -f llvm/include/llvm/Config/Disassemblers.def
834
+	rm -f llvm/include/llvm/System/DataTypes.h llvm/include/llvm/Config/Targets.def
834 835
 	rm -f llvm/tools/llvmc/plugins/Base/Base.td llvm/tools/llvm-config/llvm-config.in
835 836
 	rm -f llvm/include/llvm/Config/AsmParsers.def
836 837
 
... ...
@@ -6659,7 +6659,8 @@ distclean-local:
6659 6659
 	rm -f llvm/mklib llvm/tools/Makefile llvm/tools/llvmc/llvm-config.in llvm/utils/Makefile
6660 6660
 	rm -f llvm/Makefile.common llvm/Makefile.config llvm/config.log llvm/unittests/Makefile
6661 6661
 	rm -f llvm/llvm.spec llvm/include/llvm/Config/AsmPrinters.def llvm/include/llvm/Config/config.h
6662
-	rm -f llvm/include/llvm/Support/DataTypes.h llvm/include/llvm/Config/Targets.def
6662
+	rm -f llvm/include/llvm/Config/Disassemblers.def
6663
+	rm -f llvm/include/llvm/System/DataTypes.h llvm/include/llvm/Config/Targets.def
6663 6664
 	rm -f llvm/tools/llvmc/plugins/Base/Base.td llvm/tools/llvm-config/llvm-config.in
6664 6665
 	rm -f llvm/include/llvm/Config/AsmParsers.def
6665 6666
 
... ...
@@ -1290,3 +1290,7 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
1290 1290
 }
1291 1291
 
1292 1292
 int have_clamjit=1;
1293
+void cli_bytecode_printversion()
1294
+{
1295
+  cl::PrintVersionMessage();
1296
+}
... ...
@@ -168,6 +168,7 @@ CLAMAV_PRIVATE {
168 168
     funmap;
169 169
     cli_bytecode_context_set_trace;
170 170
     cli_bytecode_debug_printsrc;
171
+    cli_bytecode_printversion;
171 172
   local:
172 173
     *;
173 174
 };
... ...
@@ -2214,7 +2214,7 @@ int cli_scanpe(cli_ctx *ctx, unsigned int *icongrps1, unsigned int *icongrps2)
2214 2214
     pedata.exe_info.section = exe_sections;
2215 2215
     pedata.exe_info.nsections = nsections;
2216 2216
     pedata.exe_info.ep = ep;
2217
-    pedata.exe_info.offset = offset;
2217
+    pedata.exe_info.offset = 0;
2218 2218
     pedata.file_hdr = &file_hdr;
2219 2219
     pedata.opt32 = &pe_opt.opt32;
2220 2220
     pedata.opt64 = &pe_opt.opt64;