From 67bed0c13fc5544d6d164c7b5bcb043325bf789c Mon Sep 17 00:00:00 2001
From: Marios Makassikis <mmakassikis@freebox.fr>
Date: Thu, 5 Sep 2024 11:50:49 +0200
Subject: [PATCH] ksmbd-tools: fix possible crash in __mmap_parse_file

memchr() result check was dropped in a7c6eb2b1562 ("ksmbd-tools: fix
off-by-one bug and simplify __mmap_parse_file())

Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
---
 lib/config_parser.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/config_parser.c b/lib/config_parser.c
index faa4228e7631..cad2d2d60bfa 100644
--- a/lib/config_parser.c
+++ b/lib/config_parser.c
@@ -229,6 +229,8 @@ static int __mmap_parse_file(const char *path, process_entry_fn *process_entry)
 		g_autofree char *entry = NULL;
 
 		delim = memchr(contents, '\n', len) ?: contents + len;
+		if (!delim)
+			delim = contents + len - 1;
 		entry = g_strndup(contents, delim - contents);
 		ret = process_entry(entry);
 		if (ret ||
-- 
2.34.1

