Browse code

Fix bugs

Shawn Webb authored on 2013/10/29 00:21:51
Showing 4 changed files
... ...
@@ -113,6 +113,15 @@ char *export_stats_to_json(struct cl_engine *engine, cli_intel_t *intel)
113 113
         if (!(buf))
114 114
             return NULL;
115 115
 
116
+        snprintf(buf+curused, bufsz-curused, "\t\t\t\"hits\": \"%s\",\n", md5);
117
+        curused += strlen(buf+curused);
118
+
119
+        snprintf(md5, sizeof(md5), "%zu", sample->size);
120
+
121
+        buf = ensure_bufsize(buf, &bufsz, curused, strlen(md5) + 20);
122
+        if (!(buf))
123
+            return NULL;
124
+
116 125
         snprintf(buf+curused, bufsz-curused, "\t\t\t\"size\": \"%s\",\n", md5);
117 126
         curused += strlen(buf+curused);
118 127
 
... ...
@@ -398,7 +398,7 @@ struct cl_engine *cl_engine_new(void)
398 398
     }
399 399
 #endif
400 400
     intel->engine = new;
401
-    intel->maxsamples = 10;
401
+    intel->maxsamples = STATS_MAX_SAMPLES;
402 402
     new->stats_data = intel;
403 403
     new->cb_stats_add_sample = clamav_stats_add_sample;
404 404
     new->cb_stats_submit = clamav_stats_submit;
... ...
@@ -139,6 +139,7 @@ typedef struct cli_ctx_tag {
139 139
 } cli_ctx;
140 140
 
141 141
 #define STATS_ANON_UUID "5b585e8f-3be5-11e3-bf0b-18037319526c"
142
+#define STATS_MAX_SAMPLES 50
142 143
 
143 144
 typedef struct cli_flagged_sample {
144 145
     char **virus_name;
... ...
@@ -35,7 +35,7 @@ void clamav_stats_add_sample(const char *virname, const unsigned char *md5, size
35 35
 
36 36
     intel = (cli_intel_t *)cbdata;
37 37
 
38
-    if (intel->nsamples + 1 >= intel->maxsamples) {
38
+    if (intel->maxsamples && intel->nsamples + 1 >= intel->maxsamples) {
39 39
         if (!(intel->engine))
40 40
             return;
41 41