From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1169 invoked by alias); 8 May 2009 22:05:41 -0000 Received: (qmail 1153 invoked by uid 22791); 8 May 2009 22:05:40 -0000 X-SWARE-Spam-Status: No, hits=0.2 required=5.0 tests=AWL,BAYES_40,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 May 2009 22:05:34 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1M2YC9-0004Tm-PN for ecos-discuss@sources.redhat.com; Fri, 08 May 2009 22:05:29 +0000 Received: from 69.34.67.62 ([69.34.67.62]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 May 2009 22:05:29 +0000 Received: from grante by 69.34.67.62 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 May 2009 22:05:29 +0000 To: ecos-discuss@sources.redhat.com From: Grant Edwards Date: Fri, 08 May 2009 22:05:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: slrn/pre0.9.9-102 (Linux) 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: [ECOS] Re: SNMP lockup X-SW-Source: 2009-05/txt/msg00040.txt.bz2 >> 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; } -- Grant Edwards grante Yow! over in west at Philadelphia a puppy is visi.com vomiting ... -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss