goto continue_loop;
}
+#ifdef FUZZING
+ /*
+ * The stream read over in zserv_read
+ * already guarantees this conditional
+ * when we read actual packets from clients
+ * but since we are cheating there is no
+ * point in allowing a crash in the fuzzing
+ * here. So let's prevent it.
+ */
+ if (STREAM_READABLE(msg) < ZEBRA_HEADER_SIZE)
+ goto continue_loop;
+#endif
zapi_parse_header(msg, &hdr);
+#ifdef FUZZING
+ /*
+ * The stream read over in zserv_read
+ * already guarantees the sizing of the packet
+ * before it can even be enqueued but FUZZING
+ * is cheating and calling this function directly
+ * Let's cut to the chase and prevent a crash
+ * because we have a funny header size -vs-
+ * what we can read.
+ */
+ if (STREAM_SIZE(msg) != hdr.length)
+ goto continue_loop;
+#endif
+
if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV
&& IS_ZEBRA_DEBUG_DETAIL)
zserv_log_message(NULL, msg, &hdr);