sgrubb c7215b
diff -urp audit-2.6.5.orig/audisp/audispd.c audit-2.6.5/audisp/audispd.c
sgrubb c7215b
--- audit-2.6.5.orig/audisp/audispd.c	2016-07-08 12:17:53.000000000 -0400
sgrubb c7215b
+++ audit-2.6.5/audisp/audispd.c	2016-07-08 17:11:18.659015835 -0400
sgrubb c7215b
@@ -825,13 +825,25 @@ static void process_inbound_event(int fd
sgrubb c7215b
 
sgrubb c7215b
 	if (rc > 0) {
sgrubb c7215b
 		/* Sanity check */
sgrubb c7215b
-		if (!(e->hdr.ver == AUDISP_PROTOCOL_VER || 
sgrubb c7215b
-				e->hdr.ver == AUDISP_PROTOCOL_VER2) ||
sgrubb c7215b
-				e->hdr.hlen != sizeof(e->hdr) ||
sgrubb c7215b
-				e->hdr.size > MAX_AUDIT_MESSAGE_LENGTH) {
sgrubb c7215b
+		if ((e->hdr.ver != AUDISP_PROTOCOL_VER &&
sgrubb c7215b
+				e->hdr.ver != AUDISP_PROTOCOL_VER2)) {
sgrubb c7215b
+			syslog(LOG_ERR,
sgrubb c7215b
+				"Unknown dispatcher protocol %u, exiting",
sgrubb c7215b
+					e->hdr.ver);
sgrubb c7215b
 			free(e);
sgrubb c7215b
+			exit(1);
sgrubb c7215b
+		}
sgrubb c7215b
+		if (e->hdr.hlen != sizeof(e->hdr)) {
sgrubb c7215b
 			syslog(LOG_ERR,
sgrubb c7215b
-				"Dispatcher protocol mismatch, exiting");
sgrubb c7215b
+				    "Header length mismatch %u %lu, exiting",
sgrubb c7215b
+					e->hdr.hlen, sizeof(e->hdr));
sgrubb c7215b
+			free(e);
sgrubb c7215b
+			exit(1);
sgrubb c7215b
+		}
sgrubb c7215b
+		if (e->hdr.size > MAX_AUDIT_MESSAGE_LENGTH) {
sgrubb c7215b
+			syslog(LOG_ERR,	"Header size mismatch %d, exiting",
sgrubb c7215b
+					e->hdr.size);
sgrubb c7215b
+			free(e);
sgrubb c7215b
 			exit(1);
sgrubb c7215b
 		}
sgrubb c7215b
 
sgrubb c7215b
diff -urp audit-2.6.5.orig/src/auditd-dispatch.c audit-2.6.5/src/auditd-dispatch.c
sgrubb c7215b
--- audit-2.6.5.orig/src/auditd-dispatch.c	2016-07-08 12:17:53.000000000 -0400
sgrubb c7215b
+++ audit-2.6.5/src/auditd-dispatch.c	2016-07-08 17:00:58.081896384 -0400
sgrubb c7215b
@@ -183,17 +183,19 @@ int dispatch_event(const struct audit_re
sgrubb c7215b
 	hdr.ver = protocol_ver;
sgrubb c7215b
 	hdr.hlen = sizeof(struct audit_dispatcher_header);
sgrubb c7215b
 	hdr.type = rep->type;
sgrubb c7215b
-	hdr.size = rep->len;
sgrubb c7215b
 
sgrubb c7215b
 	vec[0].iov_base = (void*)&hd;;
sgrubb c7215b
 	vec[0].iov_len = sizeof(hdr);
sgrubb c7215b
 	if (protocol_ver == AUDISP_PROTOCOL_VER) {
sgrubb c7215b
+		hdr.size = rep->msg.nlh.nlmsg_len;
sgrubb c7215b
 		vec[1].iov_base = (void*)rep->message;
sgrubb c7215b
 		vec[1].iov_len = rep->msg.nlh.nlmsg_len;
sgrubb c7215b
-	} else {
sgrubb c7215b
+	} else if (protocol_ver == AUDISP_PROTOCOL_VER2) {
sgrubb c7215b
+		hdr.size = rep->len;
sgrubb c7215b
 		vec[1].iov_base = (void*)rep->msg.data;
sgrubb c7215b
 		vec[1].iov_len = rep->len;
sgrubb c7215b
-	}
sgrubb c7215b
+	} else
sgrubb c7215b
+		return 0;
sgrubb c7215b
 
sgrubb c7215b
 	do {
sgrubb c7215b
 		rc = writev(disp_pipe[1], vec, 2);