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/ripd/rip_zebra.c b/ripd/rip_zebra.c
index 1411cd7..2670ff7 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -135,7 +135,8 @@
unsigned long ifindex;
struct in_addr nexthop;
struct prefix_ipv4 p;
-
+ unsigned char plength = 0;
+
s = zclient->ibuf;
ifindex = 0;
nexthop.s_addr = 0;
@@ -148,7 +149,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));
/* Nexthop, ifindex, distance, metric. */