The patch below removes a log_warn in case the server does not find
a custom error page as this is nothing to warn about (either because
the generic template file [err.html] is used or fallback to built-in
pages is intended). It also removes two unnecessary assignments and
adapts the comment to the implementation.



Index: usr.sbin/httpd/server_http.c
===================================================================
RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
retrieving revision 1.149
diff -u -p -u -p -r1.149 server_http.c
--- usr.sbin/httpd/server_http.c        11 Nov 2021 15:52:33 -0000      1.149
+++ usr.sbin/httpd/server_http.c        5 Dec 2021 07:21:37 -0000
@@ -1759,22 +1759,20 @@ server_httperror_cmp(const void *a, cons
 }
 
 /*
- * return -1 on failure, strlen() of read file otherwise.
- * body is NULL on failure, contents of file with trailing \0 otherwise.
+ * return NULL if file does not exist or on failure,
+ * contents of file with trailing \0 otherwise.
  */
 char *
 read_errdoc(const char *root, const char *file)
 {
        struct stat      sb;
-       char            *path;
+       char            *path, *ret;
        int              fd;
-       char            *ret = NULL;
 
        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__);
                return (NULL);
        }
        free(path);
@@ -1791,8 +1789,7 @@ read_errdoc(const char *root, const char
                log_warn("%s: read", __func__);
                close(fd);
                free(ret);
-               ret = NULL;
-               return (ret);
+               return (NULL);
        }
        close(fd);
 

Reply via email to