From 50c65ae25e64b7bd4489ce22a4c7789fa9a81f2f Mon Sep 17 00:00:00 2001
From: Steve Grubb <sgrubb@redhat.com>
Date: Sat, 7 Aug 2021 11:33:20 -0400
Subject: [PATCH 2197/2246] Dont run off the end with corrupt logs

---
 src/ausearch-parse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c
index 81ef319..d051137 100644
--- a/src/ausearch-parse.c
+++ b/src/ausearch-parse.c
@@ -1031,7 +1031,7 @@ static int parse_user(const lnode *n, search_items *s, anode *avc)
 		if (str) {
 			str += 5;
 			term = str;
-			while (*term != ' ' && *term != ':')
+			while (*term != ' ' && *term != ':' && *term)
 				term++;
 			if (term == str)
 				return 24;
@@ -1244,7 +1244,7 @@ skip:
 				char *end = str;
 				int legacy = 0;
 
-				while (*end != ' ') {
+				while (*end != ' ' && *end) {
 					if (!isxdigit(*end)) {
 						legacy = 1;
 					}
@@ -1295,7 +1295,7 @@ skip:
 				char *end = str;
 				int legacy = 0;
 
-				while (*end != ' ') {
+				while (*end != ' ' && *end) {
 					if (!isxdigit(*end)) {
 						legacy = 1;
 					}
-- 
1.8.3.1

