Browse code

fix missing libxml and some windows related issues in OpenIOC

Steven Morgan authored on 2014/03/01 09:03:25
Showing 2 changed files
... ...
@@ -26,22 +26,20 @@
26 26
 #include <dirent.h>
27 27
 #include <errno.h>
28 28
 #include <string.h>
29
+#include <openssl/ssl.h>
30
+#include <openssl/err.h>
29 31
 
30
-#if HAVE_LIBXML2
32
+#include "libclamav/crypto.h"
33
+#include "others.h"
34
+#include "openioc.h"
35
+
36
+#ifdef HAVE_LIBXML2
31 37
 #ifdef _WIN32
32 38
 #ifndef LIBXML_WRITER_ENABLED
33 39
 #define LIBXML_WRITER_ENABLED 1
34 40
 #endif
35 41
 #endif
36 42
 #include <libxml/xmlreader.h>
37
-#endif
38
-
39
-#include <openssl/ssl.h>
40
-#include <openssl/err.h>
41
-
42
-#include "libclamav/crypto.h"
43
-#include "others.h"
44
-#include "openioc.h"
45 43
 
46 44
 struct openioc_hash {
47 45
     unsigned char * hash;
... ...
@@ -165,7 +163,6 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
165 165
     const xmlChar * name;
166 166
     struct openioc_hash * elems = NULL, * elem = NULL;
167 167
     const char * iocp = NULL;
168
-    char iocname[MAXPATHLEN] = {0};
169 168
     uint16_t ioclen;
170 169
     char * virusname;
171 170
     
... ...
@@ -208,8 +205,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
208 208
     else
209 209
         iocp++;
210 210
 
211
-    strncpy(iocname, iocp, MAXPATHLEN-1);
212
-    ioclen = strlen(iocname);
211
+    ioclen = strlen(fname);
213 212
 
214 213
     if (elems != NULL) {
215 214
         if (NULL == engine->hm_hdb) {
... ...
@@ -223,7 +219,8 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
223 223
     }
224 224
 
225 225
     while (elems != NULL) {
226
-        char * hash, * sp, * vp;
226
+        const char * sp;
227
+        char * hash, * vp;
227 228
         int i, hashlen;
228 229
 
229 230
         elem = elems;
... ...
@@ -237,9 +234,9 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
237 237
             free(elem);
238 238
             continue;
239 239
         }
240
-        sp = hash+hashlen-1;
241
-        while (isspace(*sp) && sp > hash) {
242
-            *sp-- = '\0';
240
+        vp = hash+hashlen-1;
241
+        while (isspace(*vp) && vp > hash) {
242
+            *vp-- = '\0';
243 243
             hashlen--;
244 244
         }
245 245
         virusname = cli_malloc(ioclen+hashlen+2);
... ...
@@ -248,7 +245,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
248 248
             return CL_EMEM;
249 249
         }
250 250
         vp = virusname;
251
-        sp = iocname;
251
+        sp = fname;
252 252
         for (i=0; i<ioclen; i++, sp++, vp++) {
253 253
             switch (*sp) {
254 254
             case '\\':
... ...
@@ -285,4 +282,12 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
285 285
         xmlFree(elem->hash);
286 286
         free(elem);
287 287
     }
288
+    return CL_SUCCESS;
288 289
 }
290
+#else
291
+int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
292
+{
293
+    cli_dbgmsg("cli_openioc: libxml2 support is compiled out and is needed for OpenIOC support.\n");
294
+    return CL_SUCCESS;
295
+}
296
+#endif
... ...
@@ -2608,6 +2608,7 @@ static int cli_loadopenioc(FILE *fs, const char *dbname, struct cl_engine *engin
2608 2608
     rc = openioc_parse(dbname, fileno(fs), engine);
2609 2609
     if (rc != CL_SUCCESS)
2610 2610
         return CL_EMALFDB;
2611
+    return rc;
2611 2612
 }
2612 2613
 
2613 2614
 static int cli_loaddbdir(const char *dirname, struct cl_engine *engine, unsigned int *signo, unsigned int options);