From: claudio Date: Tue, 13 Feb 2024 14:00:24 +0000 (+0000) Subject: Stop logging misleading errors when custom generic error pages are in use. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b32af6594337ef6e51ee8ffc41628f1f056235da;p=openbsd Stop logging misleading errors when custom generic error pages are in use. Only call the open(2) log_warn for errnos that are not ENOENT. Since that is an error worth logging. Based on a diff from Carsten Reith (carsten.reith t-online.de) OK florian@ deraadt@ --- diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 08deda7d5f0..0a814e7a656 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.153 2022/09/21 05:55:18 yasuoka Exp $ */ +/* $OpenBSD: server_http.c,v 1.154 2024/02/13 14:00:24 claudio Exp $ */ /* * Copyright (c) 2020 Matthias Pressfreund @@ -1762,13 +1762,14 @@ read_errdoc(const char *root, const char *file) struct stat sb; char *path; int fd; - char *ret = NULL; + char *ret; if (asprintf(&path, "%s/%s.html", root, file) == -1) fatal("asprintf"); if ((fd = open(path, O_RDONLY)) == -1) { free(path); - log_warn("%s: open", __func__); + if (errno != ENOENT) + log_warn("%s: open", __func__); return (NULL); } free(path); @@ -1788,8 +1789,7 @@ read_errdoc(const char *root, const char *file) log_warn("%s: read", __func__); close(fd); free(ret); - ret = NULL; - return (ret); + return (NULL); } close(fd);