fix missing libxml and some windows related issues in OpenIOC

remotes/push_mirror/0.98.2
Steven Morgan 11 years ago
parent cc284604a8
commit 53506979b1
  1. 39
      libclamav/openioc.c
  2. 1
      libclamav/readdb.c

@ -26,22 +26,20 @@
#include <dirent.h>
#include <errno.h>
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#if HAVE_LIBXML2
#include "libclamav/crypto.h"
#include "others.h"
#include "openioc.h"
#ifdef HAVE_LIBXML2
#ifdef _WIN32
#ifndef LIBXML_WRITER_ENABLED
#define LIBXML_WRITER_ENABLED 1
#endif
#endif
#include <libxml/xmlreader.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "openioc.h"
struct openioc_hash {
unsigned char * hash;
@ -165,7 +163,6 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
const xmlChar * name;
struct openioc_hash * elems = NULL, * elem = NULL;
const char * iocp = NULL;
char iocname[MAXPATHLEN] = {0};
uint16_t ioclen;
char * virusname;
@ -208,8 +205,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
else
iocp++;
strncpy(iocname, iocp, MAXPATHLEN-1);
ioclen = strlen(iocname);
ioclen = strlen(fname);
if (elems != NULL) {
if (NULL == engine->hm_hdb) {
@ -223,7 +219,8 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
}
while (elems != NULL) {
char * hash, * sp, * vp;
const char * sp;
char * hash, * vp;
int i, hashlen;
elem = elems;
@ -237,9 +234,9 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
free(elem);
continue;
}
sp = hash+hashlen-1;
while (isspace(*sp) && sp > hash) {
*sp-- = '\0';
vp = hash+hashlen-1;
while (isspace(*vp) && vp > hash) {
*vp-- = '\0';
hashlen--;
}
virusname = cli_malloc(ioclen+hashlen+2);
@ -248,7 +245,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
return CL_EMEM;
}
vp = virusname;
sp = iocname;
sp = fname;
for (i=0; i<ioclen; i++, sp++, vp++) {
switch (*sp) {
case '\\':
@ -285,4 +282,12 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
xmlFree(elem->hash);
free(elem);
}
return CL_SUCCESS;
}
#else
int openioc_parse(const char * fname, int fd, struct cl_engine *engine)
{
cli_dbgmsg("cli_openioc: libxml2 support is compiled out and is needed for OpenIOC support.\n");
return CL_SUCCESS;
}
#endif

@ -2608,6 +2608,7 @@ static int cli_loadopenioc(FILE *fs, const char *dbname, struct cl_engine *engin
rc = openioc_parse(dbname, fileno(fs), engine);
if (rc != CL_SUCCESS)
return CL_EMALFDB;
return rc;
}
static int cli_loaddbdir(const char *dirname, struct cl_engine *engine, unsigned int *signo, unsigned int options);

Loading…
Cancel
Save