From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4291 invoked by alias); 8 May 2009 22:10:56 -0000 Received: (qmail 4274 invoked by uid 22791); 8 May 2009 22:10:55 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_SORBS_WEB,SPF_PASS X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.155) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 May 2009 22:10:50 +0000 Received: by fg-out-1718.google.com with SMTP id e21so565901fga.22 for ; Fri, 08 May 2009 15:10:47 -0700 (PDT) Received: by 10.86.1.1 with SMTP id 1mr4084638fga.0.1241820647692; Fri, 08 May 2009 15:10:47 -0700 (PDT) Received: from smtp.gmail.com ([93.84.49.137]) by mx.google.com with ESMTPS id d6sm2290647fga.17.2009.05.08.15.10.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 08 May 2009 15:10:47 -0700 (PDT) Date: Fri, 08 May 2009 22:10:00 -0000 From: Sergei Gavrikov To: Grant Edwards Cc: ecos-discuss@sources.redhat.com Message-ID: <20090508221045.GA13907@ubuntu.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] Re: SNMP lockup X-SW-Source: 2009-05/txt/msg00041.txt.bz2 On Fri, May 08, 2009 at 10:05:13PM +0000, Grant Edwards wrote: > >> It appears that in mibgroup/mibII/interfaces.c, the call to > >> > >> cyg_snmp_get_if(if_num) > >> > >> with if_num==0 never returns. > > > > struct ifnet *cyg_snmp_get_if(int if_num) { > > int index = 0; > > struct ifnet *ifp; > > > > do { > > while(0 == ifnet_addrs[index]) > > index++; > > > > ifp = ifnet_addrs[index]->ifa_ifp; > > > > if_num--; > > index++; > > } while (if_num); > > > > return ifp; > > } > > > > If the above code is called with if_num==0, won't it decrement > > it to -1, and then loop 2^32 times before giving up? > > It also mis-handles negative values in a similar manner. > > Adding a check seems to fix things: > > struct ifnet *cyg_snmp_get_if(int if_num) { > int index = 0; > struct ifnet *ifp; > > if (if_num <= 0) > return NULL; > > do { > > [...] > > It should also probably check to make sure index doesn't go off > then end of if_addrs[] when large positive numbers are passed. > Perhaps something like this: > > struct ifnet *cyg_snmp_get_if(int if_num) > { > int index = 0; > struct ifnet *ifp; > > if (if_num == 0) > return NULL; > > do > { > while (0 == ifnet_addrs[index] && index < if_index) > index++; > > if (index >= if_index) > return NULL; > > ifp = ifnet_addrs[index]->ifa_ifp; > > if_num--; > index++; > } > while (if_num); > > return ifp; > } > Hi If your guess is right... Can you walk here with/without tweaks when if_num=0 repo/devo/ecos/packages/net/snmp/agent/current/src/mibgroup/mibII/interfaces.c:398 (CVS HEAD sources) Sergei -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss