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/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 4531f13..8940455 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -832,6 +832,7 @@
struct prefix_ipv4 p;
struct external_info *ei;
struct ospf *ospf;
+ unsigned char plength = 0;
s = zclient->ibuf;
ifindex = 0;
@@ -845,7 +846,8 @@
/* IPv4 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv4));
p.family = AF_INET;
- p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, stream_getc (s));
+ plength = stream_getc (s);
+ p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, plength);
stream_get (&p.prefix, s, PSIZE (p.prefixlen));
if (IPV4_NET127(ntohl(p.prefix.s_addr)))