From 77cd87efef26e0adf277ed8a16b442a818ecec9b Mon Sep 17 00:00:00 2001 From: rofl0r Date: Fri, 27 May 2022 12:48:41 +0000 Subject: [PATCH] print error message if errorfile is configured but can't be opened also, don't use fopen(NULL) if usage of errorfiles is not configured. --- src/html-error.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/html-error.c b/src/html-error.c index 998a6ee..ccafc59 100644 --- a/src/html-error.c +++ b/src/html-error.c @@ -30,6 +30,7 @@ #include "network.h" #include "utils.h" #include "conf.h" +#include "log.h" #include @@ -188,8 +189,12 @@ int send_http_error_message (struct conn_s *connptr) connptr->error_string, add); error_file = get_html_file (connptr->error_number); - if (!(infile = fopen (error_file, "r"))) { - char *detail = lookup_variable (connptr->error_variables, "detail"); + if (!error_file || !(infile = fopen (error_file, "r"))) { + char *detail; + if (error_file) log_message (LOG_ERR, + "Error opening error file '%s' (%s)", + error_file, strerror (errno)); + detail = lookup_variable (connptr->error_variables, "detail"); return (write_message (connptr->client_fd, fallback_error, connptr->error_number, connptr->error_string,