bogofilter/0006-Fix-fgetsl-abort-120.patch
2019-02-13 09:13:03 +01:00

28 lines
804 B
Diff

From 76f398b072a805f02dc057eb896391c6ad63a78a Mon Sep 17 00:00:00 2001
From: Georg Sauthoff <mail@georg.so>
Date: Fri, 8 Feb 2019 10:53:53 +0100
Subject: [PATCH 06/11] Fix fgetsl abort (#120)
https://sourceforge.net/p/bogofilter/bugs/120/
---
src/fgetsl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/fgetsl.c b/src/fgetsl.c
index 630585f..166246f 100644
--- a/src/fgetsl.c
+++ b/src/fgetsl.c
@@ -26,6 +26,9 @@ int xfgetsl(char *buf, int max_size, FILE *in, bool no_nul_terminate)
char *end = buf + max_size; /* Physical end of buffer */
char *fin = end - (no_nul_terminate ? 0 : 1); /* Last available byte */
+ if (cp == fin && no_nul_terminate)
+ return 0;
+
if (cp >= fin) {
fprintf(stderr, "Invalid buffer size, exiting.\n");
abort();
--
2.20.1