Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/httpd Handle ENAMETOOLONG to return 404 error instea...



details:   https://anonhg.NetBSD.org/src/rev/08479fd6b033
branches:  trunk
changeset: 330276:08479fd6b033
user:      shm <shm%NetBSD.org@localhost>
date:      Wed Jul 02 13:58:09 2014 +0000

description:
Handle ENAMETOOLONG to return 404 error instead of 500.

OK mrg@

diffstat:

 libexec/httpd/bozohttpd.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r 6e6bc2f0a9d1 -r 08479fd6b033 libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Wed Jul 02 13:38:05 2014 +0000
+++ b/libexec/httpd/bozohttpd.c Wed Jul 02 13:58:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bozohttpd.c,v 1.51 2014/07/01 13:41:21 shm Exp $       */
+/*     $NetBSD: bozohttpd.c,v 1.52 2014/07/02 13:58:09 shm Exp $       */
 
 /*     $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $      */
 
@@ -1533,15 +1533,21 @@
 
        if (fd < 0) {
                debug((httpd, DEBUG_FAT, "open failed: %s", strerror(errno)));
-               if (errno == EPERM)
+               switch(errno) {
+               case EPERM:
                        (void)bozo_http_error(httpd, 403, request,
                                                "no permission to open file");
-               else if (errno == ENOENT) {
+                       break;
+               case ENAMETOOLONG:
+                       /*FALLTHROUGH*/
+               case ENOENT:
                        if (!bozo_dir_index(request, file, isindex))
                                (void)bozo_http_error(httpd, 404, request,
                                                        "no file");
-               } else
+                       break;
+               default:
                        (void)bozo_http_error(httpd, 500, request, "open file");
+               }
                goto cleanup_nofd;
        }
        if (fstat(fd, &sb) < 0) {



Home | Main Index | Thread Index | Old Index