Blame SOURCES/fapolicyd-get-line.patch

a749e0
From 84916944b481d5c478202f6c4239e4aed0731406 Mon Sep 17 00:00:00 2001
a749e0
From: Steve Grubb <sgrubb@redhat.com>
a749e0
Date: Tue, 2 Jun 2020 17:27:58 -0400
a749e0
Subject: [PATCH] Return only valid lines
a749e0
a749e0
If fapolicyd_get_line does not find a 0x0A, then we have an unterminated
a749e0
string because its too long. Only return terminated strings, otherwise
a749e0
pass NULL back.
a749e0
---
a749e0
 src/library/string-util.c | 7 ++++---
a749e0
 1 file changed, 4 insertions(+), 3 deletions(-)
a749e0
a749e0
diff --git a/src/library/string-util.c b/src/library/string-util.c
a749e0
index f991f5f..ffdc645 100644
a749e0
--- a/src/library/string-util.c
a749e0
+++ b/src/library/string-util.c
a749e0
@@ -53,15 +53,16 @@ char * fapolicyd_strtrim(char * s)
a749e0
 	return s;
a749e0
 }
a749e0
 
a749e0
-char * fapolicyd_get_line(FILE *f, char *buf)
a749e0
+char *fapolicyd_get_line(FILE *f, char *buf)
a749e0
 {
a749e0
 	if (fgets_unlocked(buf, BUFFER_MAX-1, f)) {
a749e0
 
a749e0
 		/* remove newline */
a749e0
 		char *ptr = strchr(buf, 0x0a);
a749e0
-		if (ptr)
a749e0
+		if (ptr) {
a749e0
 			*ptr = 0;
a749e0
-		return buf;
a749e0
+			return buf;
a749e0
+		}
a749e0
 	}
a749e0
 
a749e0
 	return NULL;