Source-Changes-HG archive

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

[src/trunk]: src/libexec/httpd After handling a request by sending a redirect...



details:   https://anonhg.NetBSD.org/src/rev/98918b85040b
branches:  trunk
changeset: 787636:98918b85040b
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Jun 27 11:02:20 2013 +0000

description:
After handling a request by sending a redirect, do not proceed with the normal
request handling (which would typically add error output after the end
of the redirect message).

diffstat:

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

diffs (64 lines):

diff -r 23913a4ae529 -r 98918b85040b libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Thu Jun 27 10:01:31 2013 +0000
+++ b/libexec/httpd/bozohttpd.c Thu Jun 27 11:02:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bozohttpd.c,v 1.35 2013/06/27 10:01:31 martin Exp $    */
+/*     $NetBSD: bozohttpd.c,v 1.36 2013/06/27 11:02:20 martin Exp $    */
 
 /*     $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $      */
 
@@ -1114,9 +1114,10 @@
 
 /*
  * checks to see if this request has a valid .bzredirect file.  returns
- * 0 on failure and 1 on success.
+ * 0 when no redirection happend, or 1 when handle_redirect() has been
+ * called.
  */
-static void
+static int
 check_bzredirect(bozo_httpreq_t *request)
 {
        struct stat sb;
@@ -1145,12 +1146,12 @@
        snprintf(redir, sizeof(redir), "%s/%s", dir, REDIRECT_FILE);
        if (lstat(redir, &sb) == 0) {
                if (!S_ISLNK(sb.st_mode))
-                       return;
+                       return 0;
                absolute = 0;
        } else {
                snprintf(redir, sizeof(redir), "%s/%s", dir, ABSREDIRECT_FILE);
                if (lstat(redir, &sb) < 0 || !S_ISLNK(sb.st_mode))
-                       return;
+                       return 0;
                absolute = 1;
        }
        debug((request->hr_httpd, DEBUG_FAT,
@@ -1158,7 +1159,7 @@
        rv = readlink(redir, redirpath, sizeof redirpath - 1);
        if (rv == -1 || rv == 0) {
                debug((request->hr_httpd, DEBUG_FAT, "readlink failed"));
-               return;
+               return 0;
        }
        redirpath[rv] = '\0';
        debug((request->hr_httpd, DEBUG_FAT,
@@ -1174,6 +1175,7 @@
        debug((request->hr_httpd, DEBUG_FAT,
               "check_bzredirect: new redir %s", finalredir));
        handle_redirect(request, finalredir, absolute);
+       return 1;
 }
 
 /* this fixes the %HH hack that RFC2396 requires.  */
@@ -1288,7 +1290,8 @@
                goto bad_done;
        }
 
-       check_bzredirect(request);
+       if (check_bzredirect(request))
+               return 0;
 
        if (httpd->untrustedref) {
                int to_indexhtml = 0;



Home | Main Index | Thread Index | Old Index