misc/112126: netstat segfaults on unusual ICMP statistics
Maxim Konovalov
maxim at macomnet.ru
Thu Apr 26 04:40:16 UTC 2007
The following reply was made to PR bin/112126; it has been noted by GNATS.
From: Maxim Konovalov <maxim at macomnet.ru>
To: Christoph Weber-Fahr <cwf-ml at arcor.de>
Cc: bug-followup at freebsd.org
Subject: Re: misc/112126: netstat segfaults on unusual ICMP statistics
Date: Thu, 26 Apr 2007 08:33:27 +0400 (MSD)
> > Can I suggest an alternative patch:
>
> Very funny. That's where I started - but I consider it only
> the first half of a solution. Fixing a problem isn't all,
> you should also strive to prevent its repetition.
>
> Your "fix" will break the moment someone again raises
> ICMP_MAXTYPE without changing netstat/inet.c, too.
If someone raised ICMP_MAXTYPE in netinet/ip_icmp.h the size of array
in netstat/inet.c will be raised as well automatically because it is
defined as
static const char *icmpnames[ICMP_MAXTYPE + 1]
(Perhaps I should mention that it is required to recompile the whole
world when such changes happen.)
> If you need a utility to rely on kernel interfaces, have
> it import them via includes. Defining them locally, and
> crashing when the two definitions go out of sync is just
> bad coding style.
Sure thing! ICMP_MAXTYPE is coming from netinet/ip_icmp.h, there is
no local definition.
In your solution you have a local hardcored magic constant
max_known_icmpname.
--
Maxim Konovalov
More information about the freebsd-bugs
mailing list