Blame SOURCES/fapolicyd-get-line.patch

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