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.
This commit is contained in:
rofl0r 2022-05-27 12:48:41 +00:00
parent 7d1e86ccae
commit 77cd87efef

View File

@ -30,6 +30,7 @@
#include "network.h" #include "network.h"
#include "utils.h" #include "utils.h"
#include "conf.h" #include "conf.h"
#include "log.h"
#include <regex.h> #include <regex.h>
@ -188,8 +189,12 @@ int send_http_error_message (struct conn_s *connptr)
connptr->error_string, add); connptr->error_string, add);
error_file = get_html_file (connptr->error_number); error_file = get_html_file (connptr->error_number);
if (!(infile = fopen (error_file, "r"))) { if (!error_file || !(infile = fopen (error_file, "r"))) {
char *detail = lookup_variable (connptr->error_variables, "detail"); 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, return (write_message (connptr->client_fd, fallback_error,
connptr->error_number, connptr->error_number,
connptr->error_string, connptr->error_string,