Mailing List Archive

bug in packet-bgp.c (Ethereal) and print-bgp.c (tcpdump)
-------------------
The Ethereal project is being continued at a new site. Please go to
http://www.wireshark.org and subscribe to wireshark-dev@wireshark.org.
Don't forget to unsubscribe from this list at
http://www.ethereal.com/mailman/listinfo/ethereal-dev
-------------------

The expression (BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA) will always
evaluate to 1. As well, neither of these constants are defined as flag
values, so a bitwise op was probably not intended either.

Commit log for packet-bgp.c in Ethereal shows that this code originated
from Aamer Akhter, and was later ported to tcpdump by Hannes Gredler. I
am CC'ing both of them for comment.

Below is my attempt to fix the code in both projects. Is it correct?
(This is untested, I don't have a trace to test with.)

ethereal patch:
--- packet-bgp.c.orig Thu Oct 5 19:59:25 2006
+++ packet-bgp.c Thu Oct 5 20:00:40 2006
@@ -2268,7 +2268,7 @@
/* always print E2 even if not external route -- receiving router should ignore */
if ( (tvb_get_guint8(tvb,q+7)) & BGP_OSPF_RTYPE_METRIC_TYPE ) {
junk_gbuf_ptr += g_snprintf(junk_gbuf_ptr, MAX_STR_LEN-(junk_gbuf_ptr-junk_gbuf), " E2");
- } else if (tvb_get_guint8(tvb,q+6)==(BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA ) ) {
+ } else if ( (tvb_get_guint8(tvb,q+6)==BGP_OSPF_RTYPE_EXT) || (tvb_get_guint8(tvb,q+6)==BGP_OSPF_RTYPE_NSSA) ) {
junk_gbuf_ptr += g_snprintf(junk_gbuf_ptr, MAX_STR_LEN-(junk_gbuf_ptr-junk_gbuf), " E1");
} else {
junk_gbuf_ptr += g_snprintf(junk_gbuf_ptr, MAX_STR_LEN-(junk_gbuf_ptr-junk_gbuf), ", no options");

tcpdump patch:
--- print-bgp.c.orig Thu Oct 5 19:35:04 2006
+++ print-bgp.c Thu Oct 5 19:45:35 2006
@@ -1508,7 +1508,7 @@
*(tptr+6),
tokbuf, sizeof(tokbuf)),
(*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
- (*(tptr+6) == (BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA )) ? "E1" : "");
+ ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : "");
break;
case BGP_EXT_COM_L2INFO:
printf(": %s Control Flags [0x%02x]:MTU %u",

---
Aaron Campbell <aaron@arbor.net>
Software Engineer, Arbor Networks, Inc.

_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@ethereal.com
http://www.ethereal.com/mailman/listinfo/ethereal-dev
Re: bug in packet-bgp.c (Ethereal) and print-bgp.c (tcpdump) [ In reply to ]
-------------------
The Ethereal project is being continued at a new site. Please go to
http://www.wireshark.org and subscribe to wireshark-dev@wireshark.org.
Don't forget to unsubscribe from this list at
http://www.ethereal.com/mailman/listinfo/ethereal-dev
-------------------

aaron,

i have checked in your fix into HEAD and the 3.9 branch of tcpdump
and added you to the hall of shame ;-) aka CREDITS file.

tx for your submission.

---
also ethereal is depreceated - you may want to submit your patch tothe
wireshark developers list [www.wireshark.org]

/hannes

Aaron Campbell wrote:
> The expression (BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA) will always
> evaluate to 1. As well, neither of these constants are defined as flag
> values, so a bitwise op was probably not intended either.
_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@ethereal.com
http://www.ethereal.com/mailman/listinfo/ethereal-dev