quagga: Remove double read of stream
The addition of a MIN(X,Y) with a stream_getc in the Y
causes a double read of the stream due to the way that
MIN is defined.
This fix removes a crash in all protocols.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 0caf001..c8f20d8 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -213,6 +213,7 @@
unsigned long ifindex;
struct prefix_ipv6 p;
struct in6_addr *nexthop;
+ unsigned char plength = 0;
s = zclient->ibuf;
ifindex = 0;
@@ -227,7 +228,8 @@
/* IPv6 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv6));
p.family = AF_INET6;
- p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, stream_getc (s));
+ plength = stream_getc (s);
+ p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, plength);
stream_get (&p.prefix, s, PSIZE (p.prefixlen));
/* Nexthop, ifindex, distance, metric. */