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/isisd/isis_zebra.c b/isisd/isis_zebra.c
index a1a5bea..4acaf8e 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -529,6 +529,7 @@
struct prefix *p_generic = (struct prefix*)&p;
unsigned long ifindex __attribute__ ((unused));
struct in_addr nexthop __attribute__ ((unused));
+ unsigned char plength = 0;
stream = zclient->ibuf;
memset(&api, 0, sizeof(api));
@@ -541,7 +542,8 @@
api.message = stream_getc (stream);
p.family = AF_INET;
- p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, stream_getc (stream));
+ plength = stream_getc (stream);
+ p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, plength);
stream_get (&p.prefix, stream, PSIZE (p.prefixlen));
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))