Check that note files open before reading them
This fixes the scenario where a note file referenced by a todo, event, or appointment is modified from outside the program in such a way that it cannot be opened by the program, resulting in a segmentation fault. The least surprising way to proceed is to ignore the note. Signed-off-by: Nicholas Johnson <nick@nicksphere.ch> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
ac5113640d
commit
4cd300f2c4
@ -634,6 +634,10 @@ void day_popup_item(struct day_item *day)
|
||||
|
||||
asprintf(¬epath, "%s%s", path_notes, day_item_get_note(day));
|
||||
fp = fopen(notepath, "r");
|
||||
if (fp == NULL) {
|
||||
item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event:"));
|
||||
return;
|
||||
}
|
||||
note_read_contents(note, note_size, fp);
|
||||
fclose(fp);
|
||||
mem_free(notepath);
|
||||
@ -661,6 +665,10 @@ void day_popup_item(struct day_item *day)
|
||||
|
||||
asprintf(¬epath, "%s%s", path_notes, day_item_get_note(day));
|
||||
fp = fopen(notepath, "r");
|
||||
if (fp == NULL) {
|
||||
item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment:"));
|
||||
return;
|
||||
}
|
||||
note_read_contents(note, note_size, fp);
|
||||
fclose(fp);
|
||||
mem_free(notepath);
|
||||
|
@ -327,6 +327,11 @@ void ui_todo_popup_item(void)
|
||||
|
||||
asprintf(¬epath, "%s%s", path_notes, item->note);
|
||||
fp = fopen(notepath, "r");
|
||||
if (fp == NULL) {
|
||||
item_in_popup(NULL, NULL, item->mesg, _("TODO:"));
|
||||
return;
|
||||
}
|
||||
|
||||
note_read_contents(note, note_size, fp);
|
||||
fclose(fp);
|
||||
mem_free(notepath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user