~ubuntu-branches/debian/sid/clamav/sid

« back to all changes in this revision

Viewing changes to clambc/bcrun.c

  • Committer: Package Import Robot
  • Author(s): Andreas Cadhalpun, Andreas Cadhalpun, Sebastian Andrzej Siewior, Frans Spiesschaert
  • Date: 2014-10-15 06:50:20 UTC
  • mfrom: (1.3.13) (42.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20141015065020-0cpy1hdueggaw35s
Tags: 0.98.5~rc1+dfsg-1
[ Andreas Cadhalpun ]
* Import new upstream release candidate.
* Drop patches included upstream and update the others.
* Add 4 new symbols to libclamav6.symbols.
* Fix debian/copyright.
* Update lintian overrides.
* Update Standards-Version to 3.9.6 (no changes needed).
* Add Breaks and Replaces for old clamd package to clamdscan.
* Remove unnecessary shlibs:Depends from clamav-dbg.
* Add patches to support LLVM 3.5.

[ Sebastian Andrzej Siewior ]
* Add embedded copy of libmspack to be used as fallback, when libmspack-dev
  is not available.

[ Frans Spiesschaert ]
* Updated Dutch Debconf template translation (Closes: #763634)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#endif
29
29
#include <stdlib.h>
30
30
 
31
 
#include <openssl/ssl.h>
32
 
#include <openssl/err.h>
33
 
#include "libclamav/crypto.h"
34
 
 
35
31
#include "bytecode.h"
36
32
#include "bytecode_priv.h"
37
33
#include "clamav.h"
53
49
    printf("\n");
54
50
    printf("           Clam AntiVirus: Bytecode Testing Tool %s\n",
55
51
           get_version());
56
 
    printf("           By The ClamAV Team: http://www.clamav.net/team\n");
 
52
    printf("           By The ClamAV Team: http://www.clamav.net/about.html#credits\n");
57
53
    printf("           (C) 2009 Sourcefire, Inc.\n\n");
58
54
    printf("clambc <file> [function] [param1 ...]\n\n");
59
55
    printf("    --help                 -h         Show help\n");
60
56
    printf("    --version              -V         Show version\n");
 
57
    printf("    --debug                           Show debug\n");
 
58
    printf("    --force-interpreter    -f         Force using the interpreter instead of the JIT\n");
 
59
    printf("    --trust-bytecode       -t         Trust loaded bytecode (default yes)\n");
61
60
    printf("    --info                 -i         Print information about bytecode\n");
62
61
    printf("    --printsrc             -p         Print bytecode source\n");
63
 
    printf("    --trace <level>                   Set bytecode trace level 0..7 (default 7)\n");
64
 
    printf("    --no-trace-showsource             Don't show source line during tracing\n");
 
62
    printf("    --printbcir            -c         Print IR of bytecode signature\n");
 
63
    printf("    --trace <level>        -T         Set bytecode trace level 0..7 (default 7)\n");
 
64
    printf("    --no-trace-showsource  -s         Don't show source line during tracing\n");
 
65
    printf("    --bytecode-statistics             Collect and print bytecode execution statistics\n");
65
66
    printf("    file                              file to test\n");
66
67
    printf("\n");
67
68
    return;
116
117
 
117
118
static void tracehook_op(struct cli_bc_ctx *ctx, const char *op)
118
119
{
 
120
    UNUSEDPARAM(ctx);
119
121
    fprintf(stderr, "[trace] %s\n", op);
120
122
}
121
123
 
122
124
static void tracehook_val(struct cli_bc_ctx *ctx, const char *name, uint32_t value)
123
125
{
 
126
    UNUSEDPARAM(ctx);
124
127
    fprintf(stderr, "[trace] %s = %u\n", name, value);
125
128
}
126
129
 
127
130
static void tracehook_ptr(struct cli_bc_ctx *ctx, const void *ptr)
128
131
{
 
132
    UNUSEDPARAM(ctx);
129
133
    fprintf(stderr, "[trace] %p\n", ptr);
130
134
}
131
135
 
133
137
static void print_src(const char *file)
134
138
{
135
139
  char buf[4096];
136
 
  int nread, i, found = 0;
 
140
  int nread, i, found = 0, lcnt = 0;
137
141
  FILE *f = fopen(file, "r");
138
142
  if (!f) {
139
143
    fprintf(stderr,"Unable to reopen %s\n", file);
142
146
  do {
143
147
    nread = fread(buf, 1, sizeof(buf), f);
144
148
    for (i=0;i<nread-1;i++) {
145
 
      if (buf[i] == '\n' && buf[i+1] == 'S') {
 
149
      if (buf[i] == '\n') {
 
150
        lcnt++;
 
151
      }
 
152
      /* skip over the logical trigger */
 
153
      if (lcnt >= 2 && buf[i] == '\n' && buf[i+1] == 'S') {
146
154
        found = 1;
147
155
        i+=2;
148
156
        break;
329
337
        cli_bytecode_describe(bc);
330
338
    } else if (optget(opts, "printsrc")->enabled) {
331
339
        print_src(opts->filename[0]);
 
340
    } else if (optget(opts, "printbcir")->enabled) {
 
341
        cli_bytetype_describe(bc);
 
342
        cli_bytevalue_describe(bc, 0);
 
343
        cli_bytefunc_describe(bc, 0);
332
344
    } else {
333
345
        cli_ctx cctx;
334
346
        struct cl_engine *engine = cl_engine_new();