fapolicyd/SOURCES/fapolicyd-get-line.patch

37 lines
973 B
Diff
Raw Normal View History

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