ClamAv.cc:47:87: error: 'CL_SCAN_STDOPT' was not declared in this scope

Bug #1813962 reported by Scotty Beamer
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
eCAP
Triaged
Undecided
Unassigned

Bug Description

Hello!
Ok, by now CentOS also has the Version clamav-devel-0.101.1-1 which solved the bug posted before. But now I get the next error message while compiling ecap:

ClamAv.cc: In member function 'virtual void Adapter::ClamAv::scan(Adapter::Answer&)':
ClamAv.cc:47:87: error: 'CL_SCAN_STDOPT' was not declared in this scope
     const int eScanResult = cl_scanfile(answer.fileName.c_str(), &virname, 0, engine, CL_SCAN_STDOPT);
                                                                                       ^
make[2]: *** [ecap_clamav_adapter_la-ClamAv.lo] Fehler 1

Revision history for this message
uxeng (listmail) wrote :

just hit this on fedora 29

excerpt
ClamAv.cc: In member function 'virtual void Adapter::ClamAv::scan(Adapter::Answer&)':
ClamAv.cc:47:87: error: 'CL_SCAN_STDOPT' was not declared in this scope
     const int eScanResult = cl_scanfile(answer.fileName.c_str(), &virname, 0, engine, CL_SCAN_STDOPT);
                                                                                       ^~~~~~~~~~~~~~
ClamAv.cc:47:87: note: suggested alternative: 'CL_DB_STDOPT'
     const int eScanResult = cl_scanfile(answer.fileName.c_str(), &virname, 0, engine, CL_SCAN_STDOPT);
                                                                                       ^~~~~~~~~~~~~~
                                                                                       CL_DB_STDOPT
make[2]: *** [Makefile:589: ecap_clamav_adapter_la-ClamAv.lo] Error 1

Revision history for this message
Mathew Yanovsky (mathew-yanovsky) wrote :

I found a thread about the same issue on Freebsd Bugzilla forum:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235002
They provided a patch for cyrusimap/cyrus-imapd that I borrowed (see below) and it worked for me, I was able to build ecap_clamav_adapter after modifying ClamAv.cc
cyrusimap/cyrus-imapd patch that I used a reference:
https://github.com/cyrusimap/cyrus-imapd/commit/09b5bf11e12185727d53a6ae06d71a767952a537#diff-e162ed934ed89d2014e496fc1961be01

This will only work with clamav-0.101.0 and above.

Patch itself:

--- ClamAv.cc.orig 2019-02-09 22:44:27.770356182 -0500
+++ ClamAv.cc.patched 2019-02-09 23:41:41.963098901 -0500
@@ -44,7 +44,12 @@
     // We assume that cl_*() functions used here are threadsafe.

     const char *virname = 0;
- const int eScanResult = cl_scanfile(answer.fileName.c_str(), &virname, 0, engine, CL_SCAN_STDOPT);
+ static struct cl_scan_options options;
+
+ memset(&options, 0, sizeof(struct cl_scan_options));
+ options.parse |= ~0; /* enable all parsers */
+
+ const int eScanResult = cl_scanfile(answer.fileName.c_str(), &virname, 0, engine, &options);

     switch (eScanResult) {
     case CL_CLEAN:

Revision history for this message
Scotty Beamer (sbeamer) wrote :

Well that solved the compile error, but the ecap_clamav_adapter.so does not work anymore with the old configurations of squid.

Revision history for this message
Scotty Beamer (sbeamer) wrote :

Sorry, i was a to fast with that response, everything works fine now.

Revision history for this message
Alex Rousskov (rousskov) wrote :

Ironically, the now-missing CL_SCAN_STDOPT constant was documented to "make your software ready for new features in the future versions of libclamav".

For the record, the constant was removed in this ClamAV commit that replaced a single options bitmask with a structure of themed options:

https://github.com/Cisco-Talos/clamav-devel/commit/048a88e61558726bd9ba66ec3195b63d61d8a430#diff-62d8b38a9494ba8e4e7a6fad6d61a935L181

The patch proposed here will fix compilation with ClamAV v0.101, but break compilation with older versions.

A better patch will make those changes conditional on CL_SCAN_STDOPT absence. There is an (imperfect) example at https://github.com/cyrusimap/cyrus-imapd/issues/2621

My biggest worry here is that it is not clear that "enabling all parsers" is sufficient for things to work correctly during runtime. In the above-referenced commit, some of the code enables other options. For example, that official ClamAV commit has the following new example code in examples/ex1.c:

    options.parse |= ~0; /* enable all parsers */
    options.general |= CL_SCAN_GENERAL_HEURISTICS; /* enable heuristic alert options */

It looks like ClamAV developers rushed this change without thinking it through. Perhaps they will polish the interface or at least document what the correct CL_SCAN_STDOPT replacement is when this new ClamAV code becomes officially stable.

Changed in ecap:
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.