Bug#644794: [PATCH] Fix buffer lengths for IPv6 adresses logging

"Thomas Preud'homme" <[email protected]> Mon, 10 Oct 2011 00:15:15 +0200
Newsgroups gmane.linux.debian.devel.bugs.general,gmane.mail.spam.dspam.devel
Message-ID <[email protected]>
Le dimanche 9 octobre 2011 19:16:58, Thomas Preud'homme a écrit :
> Le dimanche 9 octobre 2011 15:11:10, Julien Valroff a écrit :
> > Hi,
> > 
> > Here is an attempt to fix Debian bug #644794 [0] stating the logged
> > IPv6 addresses are truncated.
> > 
> > Cheers,
> > Julien
> 
> I would like to propose a patch myself too. Size of ip array should be 128
> but I'm thinking about replacing this array by a more appropriate
> structure (like union of struct in_addr or struct in6_addr). but I want to
> check it's adequate first.
> 
> Congrats for your quick reaction Julien.

Ok, it will take more time than expected because there is also some other 
place in the code which I believe assume IPv4.

egrep -In "\[32\]" **/*.c | wc -l gives 11

One exemple is in src/daemon.c around line 250. I transformed local_addr and 
remote_addr in an union of sockaddr_in and sockaddr_in6 but then the code 
needs to be adapted. I will try to finish the patch tomorrow.

Regards.
> 
> > [0] http://bugs.debian.org/644794
> > 
> > ---
> > 
> >  CHANGELOG   |    2 ++
> >  src/dspam.c |    6 +++---
> >  2 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/CHANGELOG b/CHANGELOG
> > index 0ca9952..5098f71 100644
> > --- a/CHANGELOG
> > +++ b/CHANGELOG
> > @@ -1,3 +1,5 @@
> > +[20111009:1500] jvalroff: Fix buffer lengths for IPv6 adresses logging
> > +
> > 
> >  [20111001:1200] sbajic: Fix typo and formatting issues in dspam.conf
> >  
> >  [20111001:1030] sbajic: Fix compiler warnings (unused function) in MySQL
> > 
> > driver diff --git a/src/dspam.c b/src/dspam.c
> > index 2668aba..48c12aa 100644
> > --- a/src/dspam.c
> > +++ b/src/dspam.c
> > @@ -409,7 +409,7 @@ process_message (
> > 
> >        strcmp(_ds_pref_val(ATX->PTX, "optOutClamAV"), "on"))
> >    
> >    {
> >    
> >      if (has_virus(message)) {
> > 
> > -      char ip[32];
> > +      char ip[46];
> > 
> >        CTX->result = DSR_ISSPAM;
> >        CTX->probability = 1.0;
> >        CTX->confidence = 1.0;
> > 
> > @@ -3823,7 +3823,7 @@ MEM_ALLOC:
> >   */
> >  
> >  int tracksource(DSPAM_CTX *CTX) {
> > 
> > -  char ip[32];
> > +  char ip[46];
> > 
> >    if (!dspam_getsource (CTX, ip, sizeof (ip)))
> >    {
> > 
> > @@ -4010,7 +4010,7 @@ int is_blacklisted(DSPAM_CTX *CTX, AGENT_CTX *ATX)
> > {
> > 
> >    /* No cygwin support for IP Blacklisting */
> >    return 0;
> >  
> >  #else
> > 
> > -  char ip[32];
> > +  char ip[46];
> > 
> >    int bad = 0;
> >    struct attribute *attrib;
> >    struct addrinfo *res = NULL;
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAABCAAGBQJOkhzzAAoJENADhS+9UlKeGYIP/RXyPrBgZsWdHtpo1tDuqEGS
y8hsYDkq+o/Kw1LRSoHM1ibatcljnD4gSjofk0awv9HlwBpCLmBau8eh32EcwMaE
UnNvqEWfebU+PaUFNdQsQQj+mxaLjfRllcAshC4gDxBugxFYv0YehznaslJ1ugX1
oOD1sgtr7HpmhXQVW0/9TGGNvGrJg6TPBhficajasDQPkLbjXJ9AxnfNCtWilaTG
U1KqnaROq/0iAbwqUNDi/w3r0UDUOTiHYjXgvNKOFAnLygL/1iROh5W2zf0QRFlv
b7FojDLSrM4XPsLtH+ynRCNO0ulaSepz7QRSCdinhBJdp/xRyohNO8ma2Q/1LfWp
Vlb+vW2NQFm+l/vrOxNd+lb2zupzuWxkF3yo3dYqvRTfAe/v0jcwWlYGslrtmz+e
+fR/dPdKr1j91dLUY0j2Ji3rj8ertRLinWZFzOOlHCEM57WiXnrkwMjafkbbx5pW
MdD+rD9xKpPRHwOnNM4DtorCJ+JXAhTDLKCMyHpGeZQVDq/IIUlF+ZleCUO5P/la
5Yyi7S1upiNx4qJD/HiM+Pspa1Q0DphjQ42kYZZoOvvwfpVUMc61GkmxyzY4zyy7
Is4lILcmo1fA83EVDKl7MINj+ESH047K63l+UwwnK6l2R49NZAQOBc4I3yN4lC9o
nM5idASdmZaR5Q3cty8P
=WQU1
-----END PGP SIGNATURE-----