1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
From dc63cf73781f9303ed1f12dc7e4ecfb6f3938f3c Mon Sep 17 00:00:00 2001
From: dave <dave@slackbuilds.org>
Date: Sat, 28 Jan 2023 01:51:55 +0000
Subject: [PATCH] Don't fclose(fp) if it failed to fopen()
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------true"
This is a multi-part message in MIME format.
--------------true
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
This fixes a segfault in fclose@@GLIBC_2.2.5
'calcurse -c /path/to/apts -G' segfaults at first note seen.
Split the tests @ ical.c:216 into two:
return if fopen(fp) failed.
fclose(fp) and return @ EOF.
Signed-off-by: dave <dave@slackbuilds.org>
---
src/ical.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--------------true
Content-Type: text/x-patch; name="0001-Don-t-fclose-fp-if-it-failed-to-fopen.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Don-t-fclose-fp-if-it-failed-to-fopen.patch"
diff --git a/src/ical.c b/src/ical.c
index 535bca8..4b55343 100644
--- a/src/ical.c
+++ b/src/ical.c
@@ -213,7 +213,10 @@ static void ical_export_note(FILE *stream, char *name)
int has_desc, has_prop, i;
asprintf(¬e_file, "%s/%s", path_notes, name);
- if (!(fp = fopen(note_file, "r")) || ungetc(getc(fp), fp) == EOF) {
+ if (!(fp = fopen(note_file, "r"))) {
+ return;
+ }
+ if (ungetc(getc(fp), fp) == EOF) {
fclose(fp);
return;
}
--------------true--
|