[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b
Török Edvin
edwin at clamav.net
Sun Apr 4 01:20:23 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit d4c9f766ce0818d44147864b8ee683c277cae004
Author: Török Edvin <edwin at clamav.net>
Date: Sat Feb 13 19:57:33 2010 +0200
fix clambc's printing of source code, and add separate cmdline for it.
Also disable debug by default, --debug can be used to enable.
diff --git a/clambc/bcrun.c b/clambc/bcrun.c
index d8d1a14..4fa35f0 100644
--- a/clambc/bcrun.c
+++ b/clambc/bcrun.c
@@ -51,6 +51,8 @@ static void help(void)
printf("clambc <file> [function] [param1 ...]\n\n");
printf(" --help -h Show help\n");
printf(" --version -V Show version\n");
+ printf(" --info -i Print information about bytecode\n");
+ printf(" --printsrc -p Print bytecode source\n");
printf(" --trace <level> Set bytecode trace level 0..7 (default 7)\n");
printf(" --no-trace-showsource Don't show source line during tracing\n");
printf(" file file to test\n");
@@ -120,6 +122,7 @@ static void tracehook_ptr(struct cli_bc_ctx *ctx, const void *ptr)
fprintf(stderr, "[trace] %p\n", ptr);
}
+extern uint8_t cli_debug_flag;
static void print_src(const char *file)
{
char buf[4096];
@@ -139,7 +142,8 @@ static void print_src(const char *file)
}
}
} while (!found && (nread == sizeof(buf)));
- printf("Source code:");
+ if (cli_debug_flag)
+ printf("[clambc] Source code:");
do {
for (;i+1<nread;i++) {
if (buf[i] == 'S' || buf[i] == '\n') {
@@ -149,6 +153,8 @@ static void print_src(const char *file)
putc(((buf[i]&0xf) | ((buf[i+1]&0xf)<<4)), stdout);
i++;
}
+ if (i == nread-1 && nread != 1)
+ fseek(f, -1, SEEK_CUR);
i=0;
nread = fread(buf, 1, sizeof(buf), f);
} while (nread > 0);
@@ -199,7 +205,9 @@ int main(int argc, char *argv[])
exit(3);
}
- cl_debug();
+ if (optget(opts,"debug")->enabled) {
+ cl_debug();
+ }
rc = cl_init(CL_INIT_DEFAULT);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to init libclamav: %s\n", cl_strerror(rc));
@@ -233,20 +241,22 @@ int main(int argc, char *argv[])
optfree(opts);
exit(4);
}
-
- rc = cli_bytecode_prepare(&bcs);
- if (rc != CL_SUCCESS) {
- fprintf(stderr,"Unable to prepare bytecode: %s\n", cl_strerror(rc));
- optfree(opts);
- exit(4);
- }
fclose(f);
-
- printf("Bytecode loaded\n");
- if (optget(opts, "describe")->enabled) {
+ if (cli_debug_flag)
+ printf("[clambc] Bytecode loaded\n");
+ if (optget(opts, "info")->enabled) {
cli_bytecode_describe(bc);
+ } else if (optget(opts, "printsrc")->enabled) {
print_src(opts->filename[0]);
} else {
+ rc = cli_bytecode_prepare(&bcs);
+ if (rc != CL_SUCCESS) {
+ fprintf(stderr,"Unable to prepare bytecode: %s\n", cl_strerror(rc));
+ optfree(opts);
+ exit(4);
+ }
+ if (cli_debug_flag)
+ printf("[clambc] Bytecode prepared\n");
ctx = cli_bytecode_context_alloc();
if (!ctx) {
@@ -269,7 +279,8 @@ int main(int argc, char *argv[])
funcid = atoi(opts->filename[1]);
}
cli_bytecode_context_setfuncid(ctx, bc, funcid);
- printf("Running bytecode function :%u\n", funcid);
+ if (cli_debug_flag)
+ printf("[clambc] Running bytecode function :%u\n", funcid);
if (opts->filename[1]) {
i=2;
@@ -308,9 +319,11 @@ int main(int argc, char *argv[])
fprintf(stderr,"Unable to run bytecode: %s\n", cl_strerror(rc));
} else {
uint64_t v;
- printf("Bytecode run finished\n");
+ if (cli_debug_flag)
+ printf("[clambc] Bytecode run finished\n");
v = cli_bytecode_context_getresult_int(ctx);
- printf("Bytecode returned: 0x%llx\n", (long long)v);
+ if (cli_debug_flag)
+ printf("[clambc] Bytecode returned: 0x%llx\n", (long long)v);
}
cli_bytecode_context_destroy(ctx);
}
@@ -320,6 +333,7 @@ int main(int argc, char *argv[])
optfree(opts);
if (fd != -1)
close(fd);
- printf("Exiting\n");
+ if (cli_debug_flag)
+ printf("[clambc] Exiting\n");
return 0;
}
diff --git a/shared/optparser.c b/shared/optparser.c
index bc41265..209744f 100644
--- a/shared/optparser.c
+++ b/shared/optparser.c
@@ -66,7 +66,7 @@ const struct clam_option __clam_options[] = {
{ NULL, "config-file", 0, TYPE_STRING, NULL, 0, CONFDIR_FRESHCLAM, FLAG_REQUIRED, OPT_FRESHCLAM, "", "" },
{ NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR_MILTER, FLAG_REQUIRED, OPT_MILTER, "", "" },
{ NULL, "version", 'V', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_MILTER | OPT_CLAMCONF | OPT_CLAMDTOP | OPT_CLAMBC, "", "" },
- { NULL, "debug", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_SIGTOOL, "", "" },
+ { NULL, "debug", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC | OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_SIGTOOL, "", "" },
{ NULL, "verbose", 'v', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL, "", "" },
{ NULL, "quiet", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL, "", "" },
{ NULL, "leave-temps", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" },
@@ -121,7 +121,8 @@ const struct clam_option __clam_options[] = {
{ NULL, "generate-config", 'g', TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMCONF, "", "" },
{ NULL, "force-interpreter", 'f', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Force using the interpreter instead of the JIT", "" },
- { NULL, "describe", 'd', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Load and describe bytecode without executing", ""},
+ { NULL, "info", 'i', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Load and print bytecode information without executing", ""},
+ { NULL, "printsrc", 'p', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Print source code of bytecode", ""},
{ NULL, "input", 'i', TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMBC, "Input file to run the bytecode n", ""},
{ NULL, "trace", 't', TYPE_NUMBER, MATCH_NUMBER, 7, NULL, 0, OPT_CLAMBC, "bytecode trace level",""},
{ NULL, "no-trace-showsource", 's', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMBC, "Don't show source line during tracing",""},
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list