2 --- python-clamav-0.4.1.orig/pyclamav.c
3 +++ python-clamav-0.4.1/pyclamav.c
6 /* ********************************************************* */
8 -/* To be able to compile with
9 - releases 0.75 of libclamav
11 - Where cl_free was cl_freetrie
12 - and cl_build was cl_buildtrie
13 - CL_SCAN_STDOPT did not exist
15 -#ifndef CL_SCAN_STDOPT
16 -#define CL_SCAN_STDOPT CL_RAW | CL_ARCHIVE | CL_MAIL | CL_DISABLERAR | CL_OLE2 | CL_ENCRYPTED
17 -void cl_free(struct cl_node *rootnode) {
18 - cl_freetrie(rootnode);
22 -int cl_build(struct cl_node *rootnode) {
23 - return cl_buildtrie(rootnode);
27 /* For python prior to 2.3 */
28 #ifndef PyMODINIT_FUNC
29 #define PyMODINIT_FUNC void
31 unsigned int signumber = 0;
33 /* Structures for clamav */
34 -struct cl_node *root = NULL;
35 -struct cl_limits limits;
36 +struct cl_engine *engine = NULL;
37 struct cl_stat dbstat;
41 * If the virus database has been changed, then
42 * free the current tree and reload the new one
44 /* If yes : reload DB */
45 if (cl_statchkdir(&dbstat) == 1)
49 + /* free the engine */
50 + cl_engine_free(engine);
56 - if((ret = cl_load(cl_retdbdir(), &root, &signumber, CL_DB_STDOPT))) {
57 + if((ret = cl_load(cl_retdbdir(), engine, &signumber, CL_DB_STDOPT)) != CL_SUCCESS) {
58 /* Raise exception with error message */
59 PyErr_SetString(PyclamavError, cl_strerror(ret));
63 - /* build the final tree */
64 - if((ret = cl_build(root))) {
65 - /* free the partial tree */
67 + /* prepare the engine */
68 + if((ret = cl_engine_compile(engine))) {
69 + /* free the engine */
70 + cl_engine_free(engine);
71 /* Raise exception with error message */
72 PyErr_SetString(PyclamavError, cl_strerror(ret));
78 - ret = cl_scanfile(file_to_scan, &virname, &size, root, &limits, CL_SCAN_STDOPT);
79 + ret = cl_scanfile(file_to_scan, &virname, &size, engine, CL_SCAN_STDOPT);
81 /* Test return code */
84 /* Set documentation string for the module */
85 PyDict_SetItemString(dict, "__doc__", PyString_FromString("pyclamav :\n\n This is a python binding to the C libclamav library\n (from the Clamav project - http://www.clamav.net).\n It can be used to easily allow a Python script to scan\n a file or a buffer against known viruses.\n\nAuthor : Alexandre Norman [norman@xael.org]\n\nFunctions :\n - scanfile(string filename) : Scan a file for virus.\n - get_numsig() : Return the number of known signatures.\n - get_version() : Return the version of Clamav.\n - version() : Return the version of pyclamav.\n"));
87 + /* initialize libclamav */
88 + cl_init(CL_INIT_DEFAULT);
89 + engine = cl_engine_new();
91 - if((ret = cl_load(cl_retdbdir(), &root, &signumber, CL_DB_STDOPT))) {
92 + if((ret = cl_load(cl_retdbdir(), engine, &signumber, CL_DB_STDOPT))) {
93 /* Raise exception with error message */
94 PyErr_SetString(PyclamavError, cl_strerror(ret));
95 + cl_engine_free(engine);
99 - /* build the final tree */
100 - if((ret = cl_build(root))) {
101 - /* free the partial tree */
103 + /* prepare the engine */
104 + if((ret = cl_engine_compile(engine)) != CL_SUCCESS) {
105 + /* free up the engine resources */
106 + cl_engine_free(engine);
107 /* Raise exception with error message */
108 PyErr_SetString(PyclamavError, cl_strerror(ret));
111 memset(&dbstat, 0, sizeof(struct cl_stat));
112 cl_statinidir(cl_retdbdir(), &dbstat);
116 - /* set up archive limits */
117 - memset(&limits, 0, sizeof(struct cl_limits));
118 - limits.maxfiles = 1000; /* max files */
119 - limits.maxfilesize = 10 * 1048576; /* maximal archived file size == 10 Mb */
120 - limits.maxreclevel = 5; /* maximal recursion level */
121 - limits.archivememlim = 0; /* disable memory limit for bzip2 scanner */
127 --- pyclamav-0.4.1/pyclamav.c.orig 2018-12-10 21:43:22.642033238 +0100
128 +++ pyclamav-0.4.1/pyclamav.c 2018-12-11 17:39:55.224546828 +0100
133 +#ifdef CL_SCAN_STDOPT
134 ret = cl_scanfile(file_to_scan, &virname, &size, engine, CL_SCAN_STDOPT);
137 + struct cl_scan_options scanoptions = {CL_SCAN_GENERAL_HEURISTICS,
138 + CL_SCAN_PARSE_ARCHIVE|CL_SCAN_PARSE_ELF|CL_SCAN_PARSE_PDF|CL_SCAN_PARSE_SWF|CL_SCAN_PARSE_HWP3|CL_SCAN_PARSE_XMLDOCS|CL_SCAN_PARSE_MAIL|CL_SCAN_PARSE_OLE2|CL_SCAN_PARSE_HTML|CL_SCAN_PARSE_PE,
140 + ret = cl_scanfile(file_to_scan, &virname, &size, engine, &scanoptions);
144 /* Test return code */