Re: squid3-ipv6 squid3/src snmp_core.cc,1.10.8.32,1.10.8.33

From: Amos Jeffries <squid3@dont-contact.us>
Date: Fri, 23 Nov 2007 12:06:26 +1300 (NZDT)

> Update of cvs.devel.squid-cache.org:/cvsroot/squid/squid3/src
>
> Modified Files:
> Tag: squid3-ipv6
> snmp_core.cc
> Log Message:
> A very hard hack to detect. Copy constructor cannot accept *NULL contents.
> This caused Squid to die some times when exploring MIB tree, specially
> when no service was attended at least one time. because the client table
> had no clients emacs snmp_core.cc! hence NULL

Sigh, this again. It's a compiler problem, not throwing up warnings when
NULL ptr is de-referenced. No hope for it but to make a fix ourselves.

I was hoping to avoid accepting ptrs in the constructor. No harm in
creating one though if we really have to and it should be safety checked
there instead of each usage point in the code.

I'm just adding one now for you.

Amos

>
> Index: snmp_core.cc
> ===================================================================
> RCS file: /cvsroot/squid/squid3/src/snmp_core.cc,v
> retrieving revision 1.10.8.32
> retrieving revision 1.10.8.33
> diff -C2 -d -r1.10.8.32 -r1.10.8.33
> *** snmp_core.cc 22 Nov 2007 17:21:58 -0000 1.10.8.32
> --- snmp_core.cc 22 Nov 2007 20:06:20 -0000 1.10.8.33
> ***************
> *** 915,921 ****
> oid *instance = NULL;
> IPAddress laddr;
>
> if (*len <= current->len) {
> ! laddr = *client_entry(NULL); // the first client on db.
> #if USE_IPV6
> int size = laddr.IsIPv4()? sizeof(in_addr) : sizeof(in6_addr) ;
> --- 915,926 ----
> oid *instance = NULL;
> IPAddress laddr;
> + IPAddress *aux;
>
> if (*len <= current->len) {
> ! aux = client_entry(NULL);
> ! // FIXME INET6 . is this good C++ style ?
> ! // What otherwise ?
> ! if (aux) laddr = *aux ; else laddr.SetAnyAddr();
> !
> #if USE_IPV6
> int size = laddr.IsIPv4()? sizeof(in_addr) : sizeof(in6_addr) ;
> ***************
> *** 923,929 ****
> int size = sizeof(in_addr);
> #endif
> instance = (oid *)xmalloc(sizeof(name) * (*len + size ));
> xmemcpy(instance, name, (sizeof(name) * (*len)));
> !
> if ( !laddr.IsAnyAddr() ) {
> addr2oid(laddr, &instance[ *len]); // the addr
> --- 928,935 ----
> int size = sizeof(in_addr);
> #endif
> +
> instance = (oid *)xmalloc(sizeof(name) * (*len + size ));
> xmemcpy(instance, name, (sizeof(name) * (*len)));
> !
> if ( !laddr.IsAnyAddr() ) {
> addr2oid(laddr, &instance[ *len]); // the addr
> ***************
> *** 933,937 ****
> int shift = *len - current->len ; // i.e 4 or 16
> oid2addr(&name[*len - shift], laddr,shift);
> ! laddr = *client_entry(&laddr);
>
> if (!laddr.IsAnyAddr()) {
> --- 939,947 ----
> int shift = *len - current->len ; // i.e 4 or 16
> oid2addr(&name[*len - shift], laddr,shift);
> ! aux = client_entry(&laddr);
> ! // FIXME INET6 . is this good C++ style ?
> ! // What otherwise ?
> ! if (aux) laddr = *aux ; else laddr.SetAnyAddr();
> !
>
> if (!laddr.IsAnyAddr()) {
>
>
Received on Thu Nov 22 2007 - 16:06:31 MST

This archive was generated by hypermail pre-2.1.9 : Sat Dec 01 2007 - 12:00:05 MST