Menu

#2 database is loaded repetitively and exhausts memory

Unstable (example)
closed
ARGOS
None
5
2014-08-05
2013-11-18
Ludmila
No

There is a problem where the cl_scanfile function will repetitively load the virus definition database over and over again if the load_db_on_startup ini is not set. If the ini is set, the php-clamav correctly loads the database only once.

Eventually, repeat calls to cl_scanfile will result in memory exhaustion due to the repetitive loading of the db.

To solve this, go into file clamav.c and change:

if (CLAMAV_G(load_db_on_startup) == 0) {
    if ((ret = clamav_load_database()) != CL_SUCCESS) {
        php_error(E_WARNING, "Load database during cl_scanfile failed : error : %i (%s)\n", ret, cl_strerror(ret));
        RETURN_FALSE;
    }
}

to this:

static int db_loaded = 0;

if ((CLAMAV_G(load_db_on_startup) == 0) && (!db_loaded)) {
    if ((ret = clamav_load_database()) != CL_SUCCESS) {
        php_error(E_WARNING, "Load database during cl_scanfile failed : error : %i (%s)\n", ret, cl_strerror(ret));
        RETURN_FALSE;
    }else{
        db_loaded = 1;
    }
}

And that will cause the database to be loaded only once in cases where load_db_on_startup ini is not set.

Discussion

  • ARGOS

    ARGOS - 2013-11-18

    Thanks for your report.
    I approve and commit your change soon.

     
  • ARGOS

    ARGOS - 2014-08-05

    Commit on svn, available into the next release.

     
  • ARGOS

    ARGOS - 2014-08-05
    • status: open --> closed
    • assigned_to: ARGOS
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.