Handle failed system calls

Introduce a separate TU for utility functions util.c. Add a function
exec_cmd to simplify execution of system commands with error handling.

While at it, suppress a warning about unused result when executing a
shell command. As we only display the command's output we do not care
about the exit code.

This fixes Debian bug #398989[0]

[0]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=398989
This commit is contained in:
Rene Kita
2022-12-25 15:11:44 +01:00
parent 7c7af9e70c
commit 4e23ee03ca
5 changed files with 44 additions and 16 deletions

6
form.c
View File

@@ -9,6 +9,7 @@
#include "myctype.h"
#include "local.h"
#include "regex.h"
#include "util.h"
extern Str *textarea_str;
extern int max_textarea;
@@ -603,9 +604,8 @@ input_textarea(FormItemList *fi)
form_fputs_decode(fi->value, f);
fclose(f);
fmTerm();
system(myEditor(Editor, tmpf, 1)->ptr);
fmInit();
if (exec_cmd(myEditor(Editor, tmpf, 1)->ptr))
goto input_end;
if (fi->readonly)
goto input_end;