From: Grant Edwards <grante@visi.com>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] Re: SNMP lockup
Date: Fri, 08 May 2009 22:05:00 -0000 [thread overview]
Message-ID: <gu2aap$8jh$1@ger.gmane.org> (raw)
In-Reply-To: <gu2875$5cq$1@ger.gmane.org>
>> 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
next prev parent reply other threads:[~2009-05-08 22:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-08 20:52 [ECOS] " Grant Edwards
2009-05-08 21:22 ` [ECOS] " Grant Edwards
2009-05-08 21:29 ` Grant Edwards
2009-05-08 21:35 ` Grant Edwards
2009-05-08 22:05 ` Grant Edwards [this message]
2009-05-08 22:10 ` Sergei Gavrikov
2009-05-08 22:38 ` Grant Edwards
2009-05-08 23:10 ` Sergei Gavrikov
2009-05-08 23:15 ` Gary Thomas
2009-05-08 23:44 ` Sergei Gavrikov
2009-05-09 8:48 ` Grant Edwards
2009-05-09 9:20 ` Sergei Gavrikov
2009-05-09 9:47 ` Grant Edwards
2009-05-09 10:28 ` Grant Edwards
2009-05-09 12:38 ` Sergei Gavrikov
2009-05-14 8:26 ` [ECOS] " Danny Sade
2009-05-14 15:03 ` [ECOS] " Grant Edwards
2009-05-14 19:50 ` Grant Edwards
2009-05-08 22:11 ` Grant Edwards
2009-05-09 8:22 ` Grant Edwards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='gu2aap$8jh$1@ger.gmane.org' \
--to=grante@visi.com \
--cc=ecos-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).