[Pkg-clamav-devel] tommath

Sebastian Andrzej Siewior sebastian at breakpoint.cc
Sun Nov 30 21:08:19 UTC 2014


We pass --with-system-tommath to configure and build-depend on
libtommath-dev. And yet it fails to build on x32 due to a something in
tommath. I've been asking myself how can that be for a while now. And
today I found some time to look at it and well…

The argument we pass is pointless. libclamav is always built with the
internal copy of tommath. So I ripped it off, linked against the system
library and tried a build. It failed and complained about a missing
function, so I applied this:

--- a/libclamav/asn1.c
+++ b/libclamav/asn1.c
@@ -850,18 +850,14 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
             /* Dump the cert if requested before anything happens to it */
             if (engine->dconf->pe & PE_CONF_DUMPCERT) {
                 char issuer[SHA1_HASH_SIZE*2+1], subject[SHA1_HASH_SIZE*2+1], serial[SHA1_HASH_SIZE*2+1];
-                char mod[1024], exp[1024];
                 int j=1024;
 
-                fp_toradix_n(&x509->n, mod, 16, j);
-                fp_toradix_n(&x509->e, exp, 16, j);
                 for (j=0; j < SHA1_HASH_SIZE; j++) {
                     sprintf(&issuer[j*2], "%02x", x509->issuer[j]);
                     sprintf(&subject[j*2], "%02x", x509->subject[j]);
                     sprintf(&serial[j*2], "%02x", x509->serial[j]);
                 }
 
-                cli_dbgmsg_internal("cert subject:%s serial:%s pubkey:%s i:%s %lu->%lu %s %s %s\n", subject, serial, mod, issuer, (unsigned long)x509->not_before, (unsigned long)x509->not_after, x509->certSign ? "cert" : "", x509->codeSign ? "code" : "", x509->timeSign ? "time" : "");
             }
 
 		    if(parent) {


After that it built and the test-suite passed as well. One of mod + exp (the
output of fp_toradix_n() is only used in cli_dbgmsg_internal() so I
doubt that it is a big loss. And I am not sure that function does what
one expects it to do because the prototype is
 int fp_toradix_n(fp_int *a, char *str, int radix, int maxlen);

and x509 which is of type cli_crt which goes like this:
 typedef struct cli_crt_t {
…
     mp_int n;
     mp_int e;
     mp_int sig;
…
 } cli_crt;

The fp_ prefix is from tomfastmath while the other is tommath so it might
be a leftover.
I will open a bug with a patch where we really can use external
libtommath…

Sebastian



More information about the Pkg-clamav-devel mailing list