Mailing List Archive

Help to fix some code with new API
Hello,

I want to update clamav to 0.95 on FreeBSD ports collection, but,
before it I need to have all dependant ports working fine.

I've contacted some maintainers / authors and got fixes, but, there
are 2 of them missing and I tried to fix it by myself.

Could anyone take a look at those patches and let me know if I
missed something? They are building fine, but it doesn't mean
they are working fine.

Here are the patches:

http://people.freebsd.org/~garga/patches/patch-mod_clamav.c
http://people.freebsd.org/~garga/patches/patch-src__clam.cpp

Thanks in advance
--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Renato Botelho wrote:
> Hello,
>
> I want to update clamav to 0.95 on FreeBSD ports collection, but,
> before it I need to have all dependant ports working fine.
>
> I've contacted some maintainers / authors and got fixes, but, there
> are 2 of them missing and I tried to fix it by myself.
>
> Could anyone take a look at those patches and let me know if I
> missed something? They are building fine, but it doesn't mean
> they are working fine.
>

- - limits are gone
- - you should use cl_engine_set_num() to set maxfilesize and friends
- - you need cl_init(CL_INIT_DEFAULT)

Regards


- --
Gianluigi Tiesi <sherpya@netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknKZoAACgkQ3UE5cRfnO065xwCglp5XfdAaKsPUSN11B3Mfxdgq
Vr4AoJf5gVCH0uRCK3JDhTvVU6rG196/
=XZS6
-----END PGP SIGNATURE-----
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed, Mar 25, 2009 at 2:14 PM, Gianluigi Tiesi <sherpya@netfarm.it> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Renato Botelho wrote:
>> Hello,
>>
>> I want to update clamav to 0.95 on FreeBSD ports collection, but,
>> before it I need to have all dependant ports working fine.
>>
>> I've contacted some maintainers / authors and got fixes, but, there
>> are 2 of them missing and I tried to fix it by myself.
>>
>> Could anyone take a look at those patches and let me know if I
>> missed something? They are building fine, but it doesn't mean
>> they are working fine.
>>
>
> - - limits are gone
> - - you should use cl_engine_set_num() to set maxfilesize and friends
> - - you need cl_init(CL_INIT_DEFAULT)

This sounds ok now?

static struct cl_engine *root;

if ((root = cl_init(CL_INIT_DEFAULT)))
throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_init",root);

if ((err = cl_load(cl_retdbdir(), root, &signo, CL_DB_STDOPT)))
throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_load",err);

if ((err = cl_engine_compile(root)))
throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_engine_compile",err);

cl_engine_free(root);

--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed, Mar 25, 2009 at 2:46 PM, Renato Botelho <rbgarga@gmail.com> wrote:
> On Wed, Mar 25, 2009 at 2:14 PM, Gianluigi Tiesi <sherpya@netfarm.it> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Renato Botelho wrote:
>>> Hello,
>>>
>>> I want to update clamav to 0.95 on FreeBSD ports collection, but,
>>> before it I need to have all dependant ports working fine.
>>>
>>> I've contacted some maintainers / authors and got fixes, but, there
>>> are 2 of them missing and I tried to fix it by myself.
>>>
>>> Could anyone take a look at those patches and let me know if I
>>> missed something? They are building fine, but it doesn't mean
>>> they are working fine.
>>>
>>
>> - - limits are gone
>> - - you should use cl_engine_set_num() to set maxfilesize and friends
>> - - you need cl_init(CL_INIT_DEFAULT)

Wrong code, now:

static struct cl_engine *root;

if ((err = cl_init(CL_INIT_DEFAULT)))
throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_init",err);

root = cl_engine_new();

if ((err = cl_load(cl_retdbdir(), root, &signo, CL_DB_STDOPT)))
throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_load",err);

if ((err = cl_engine_compile(root)))
throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_engine_compile",err);

cl_engine_free(root);



--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On 2009-03-25 19:54, Renato Botelho wrote:
> On Wed, Mar 25, 2009 at 2:46 PM, Renato Botelho <rbgarga@gmail.com> wrote:
>
>> On Wed, Mar 25, 2009 at 2:14 PM, Gianluigi Tiesi <sherpya@netfarm.it> wrote:
>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Renato Botelho wrote:
>>>
>>>> Hello,
>>>>
>>>> I want to update clamav to 0.95 on FreeBSD ports collection, but,
>>>> before it I need to have all dependant ports working fine.
>>>>
>>>> I've contacted some maintainers / authors and got fixes, but, there
>>>> are 2 of them missing and I tried to fix it by myself.
>>>>
>>>> Could anyone take a look at those patches and let me know if I
>>>> missed something? They are building fine, but it doesn't mean
>>>> they are working fine.
>>>>
>>>>
>>> - - limits are gone
>>> - - you should use cl_engine_set_num() to set maxfilesize and friends
>>> - - you need cl_init(CL_INIT_DEFAULT)
>>>
>
> Wrong code, now:
>
> static struct cl_engine *root;
>
> if ((err = cl_init(CL_INIT_DEFAULT)))
> throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_init",err);
>
> root = cl_engine_new();
>

You should check for failure here (== NULL).

> if ((err = cl_load(cl_retdbdir(), root, &signo, CL_DB_STDOPT)))
> throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_load",err);
>
> if ((err = cl_engine_compile(root)))
> throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_engine_compile",err);
>
> cl_engine_free(root);
>

You should check for error here too.

Yes, that should be right, see also
https://wiki.clamav.net/Main/UpgradeNotes095#Upgrading_to_the_new_libclamav_A

When you are done upgrading it would be nice to test these programs by
trying to scan test/clam.exe.

Best regards,
--Edwin
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed, Mar 25, 2009 at 2:14 PM, Gianluigi Tiesi <sherpya@netfarm.it> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Renato Botelho wrote:
>> Hello,
>>
>> I want to update clamav to 0.95 on FreeBSD ports collection, but,
>> before it I need to have all dependant ports working fine.
>>
>> I've contacted some maintainers / authors and got fixes, but, there
>> are 2 of them missing and I tried to fix it by myself.
>>
>> Could anyone take a look at those patches and let me know if I
>> missed something? They are building fine, but it doesn't mean
>> they are working fine.
>>
>
> - - limits are gone
> - - you should use cl_engine_set_num() to set maxfilesize and friends
> - - you need cl_init(CL_INIT_DEFAULT)
>
> Regards
>
>
> - --
> Gianluigi Tiesi <sherpya@netfarm.it>
> EDP Project Leader
> Netfarm S.r.l. - http://www.netfarm.it/
> Free Software: http://oss.netfarm.it/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAknKZoAACgkQ3UE5cRfnO065xwCglp5XfdAaKsPUSN11B3Mfxdgq
> Vr4AoJf5gVCH0uRCK3JDhTvVU6rG196/
> =XZS6
> -----END PGP SIGNATURE-----
> _______________________________________________
> http://lurker.clamav.net/list/clamav-devel.html
> Please submit your patches to our Bugzilla: http://bugs.clamav.net
>


And for the other one:

cfg->maxfiles = 100;
cl_engine_set_num(cfg->common->local->engine, CL_ENGINE_MAX_FILES,
&cfg->maxfiles);
cfg->maxfilesize = 10 * 1048576;
cl_engine_set_num(cfg->common->local->engine,
CL_ENGINE_MAX_FILE_SIZE, &cfg->maxfilesize);
cfg->maxreclevel = 8;
cl_engine_set_num(cfg->common->local->engine,
CL_ENGINE_MAX_RECURSION, &cfg->maxreclevel);

What do you think?

--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed Mar 25 2009 19:05:13 GMT+0100 (CET)
Renato Botelho <rbgarga@gmail.com> wrote:

> And for the other one:
> cfg->maxfiles = 100;

Setting maxfiles to such a low value is not a good idea.

--
oo ..... Tomasz Kojm <tkojm@clamav.net>
(\/)\......... http://www.ClamAV.net/gpg/tkojm.gpg
\..........._ 0DCA5A08407D5288279DB43454822DC8985A444B
//\ /\ Wed Mar 25 19:05:41 CET 2009
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed, Mar 25, 2009 at 3:07 PM, Tomasz Kojm <tkojm@clamav.net> wrote:
> On Wed Mar 25 2009 19:05:13 GMT+0100 (CET)
> Renato Botelho <rbgarga@gmail.com> wrote:
>
>> And for the other one:
>>     cfg->maxfiles = 100;
>
> Setting maxfiles to such a low value is not a good idea.

I'm just trying to fix a third part program to use new API, this
is not my software.

I'll say this to author, thanks!

And about the way I did the changes, is it ok?

--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed Mar 25 2009 19:11:36 GMT+0100 (CET)
Renato Botelho <rbgarga@gmail.com> wrote:

> And about the way I did the changes, is it ok?

Yes, generally the changes look OK (however without complete source
files I can't say there are no memleaks when some exceptions get raised,
etc.), but you should make some real world tests of these applications
to make sure they're functioning correctly.

--
oo ..... Tomasz Kojm <tkojm@clamav.net>
(\/)\......... http://www.ClamAV.net/gpg/tkojm.gpg
\..........._ 0DCA5A08407D5288279DB43454822DC8985A444B
//\ /\ Wed Mar 25 19:15:02 CET 2009
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
On Wed, Mar 25, 2009 at 3:24 PM, Tomasz Kojm <tkojm@clamav.net> wrote:
> On Wed Mar 25 2009 19:11:36 GMT+0100 (CET)
> Renato Botelho <rbgarga@gmail.com> wrote:
>
>> And about the way I did the changes, is it ok?
>
> Yes, generally the changes look OK (however without complete source
> files I can't say there are no memleaks when some exceptions get raised,
> etc.), but you should make some real world tests of these applications
> to make sure they're functioning correctly.
>
> --
>   oo    .....         Tomasz Kojm <tkojm@clamav.net>
>  (\/)\.........         http://www.ClamAV.net/gpg/tkojm.gpg
>     \..........._         0DCA5A08407D5288279DB43454822DC8985A444B
>       //\   /\              Wed Mar 25 19:15:02 CET 2009
> _______________________________________________
> http://lurker.clamav.net/list/clamav-devel.html
> Please submit your patches to our Bugzilla: http://bugs.clamav.net
>

If you have some time to take a look....

http://people.freebsd.org/~garga/clamav-update/clam.cpp
http://people.freebsd.org/~garga/clamav-update/clam.h
http://people.freebsd.org/~garga/clamav-update/mod_clamav.c

Thanks
--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
Re: Help to fix some code with new API [ In reply to ]
2009/3/25 Török Edwin <edwintorok@gmail.com>:
> On 2009-03-25 19:54, Renato Botelho wrote:
>> On Wed, Mar 25, 2009 at 2:46 PM, Renato Botelho <rbgarga@gmail.com> wrote:
>>
>>> On Wed, Mar 25, 2009 at 2:14 PM, Gianluigi Tiesi <sherpya@netfarm.it> wrote:
>>>
>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>> Hash: SHA1
>>>>
>>>> Renato Botelho wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I want to update clamav to 0.95 on FreeBSD ports collection, but,
>>>>> before it I need to have all dependant ports working fine.
>>>>>
>>>>> I've contacted some maintainers / authors and got fixes, but, there
>>>>> are 2 of them missing and I tried to fix it by myself.
>>>>>
>>>>> Could anyone take a look at those patches and let me know if I
>>>>> missed something? They are building fine, but it doesn't mean
>>>>> they are working fine.
>>>>>
>>>>>
>>>> - - limits are gone
>>>> - - you should use cl_engine_set_num() to set maxfilesize and friends
>>>> - - you need cl_init(CL_INIT_DEFAULT)
>>>>
>>
>> Wrong code, now:
>>
>> static struct cl_engine *root;
>>
>>       if ((err = cl_init(CL_INIT_DEFAULT)))
>>        throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_init",err);
>>
>>      root = cl_engine_new();
>>
>
> You should check for failure here (== NULL).

I'll do

>>      if ((err = cl_load(cl_retdbdir(), root, &signo, CL_DB_STDOPT)))
>>        throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_load",err);
>>
>>      if ((err = cl_engine_compile(root)))
>>        throw cException(CLAMAV_CLASS_NAME,CLAMAV_CLASS_NAME,"cl_engine_compile",err);
>>
>>      cl_engine_free(root);
>>
>
> You should check for error here too.

I'll do too

I'll send those patches to authors and maintainers and ask him to test

Thank you
--
Renato Botelho
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net