Source-Changes-HG archive

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

[src/trunk]: src/libexec/httpd fix content type handling to not hard code (wr...



details:   https://anonhg.NetBSD.org/src/rev/ded2a3c95b0a
branches:  trunk
changeset: 337869:ded2a3c95b0a
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat May 02 11:35:48 2015 +0000

description:
fix content type handling to not hard code (wrong) values for length,
but just call strlen() as needed.  call this 20150501.

reported by Jan Danielsson for ".svg".

diffstat:

 libexec/httpd/bozohttpd.8    |    6 +-
 libexec/httpd/bozohttpd.c    |    5 +-
 libexec/httpd/bozohttpd.h    |    5 +-
 libexec/httpd/cgi-bozo.c     |    5 +-
 libexec/httpd/content-bozo.c |  270 +++++++++++++++++++++---------------------
 5 files changed, 145 insertions(+), 146 deletions(-)

diffs (truncated from 407 to 300 lines):

diff -r 0bd0740f9dab -r ded2a3c95b0a libexec/httpd/bozohttpd.8
--- a/libexec/httpd/bozohttpd.8 Sat May 02 08:00:08 2015 +0000
+++ b/libexec/httpd/bozohttpd.8 Sat May 02 11:35:48 2015 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: bozohttpd.8,v 1.50 2015/04/16 02:32:33 mrg Exp $
+.\"    $NetBSD: bozohttpd.8,v 1.51 2015/05/02 11:35:48 mrg Exp $
 .\"
 .\"    $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $
 .\"
@@ -26,7 +26,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 15, 2015
+.Dd May 1, 2015
 .Dt BOZOHTTPD 8
 .Os
 .Sh NAME
@@ -510,7 +510,7 @@
 and regular code audits.
 This manual documents
 .Nm
-version 20150320.
+version 20150501.
 .Sh AUTHORS
 .An -nosplit
 .Nm
diff -r 0bd0740f9dab -r ded2a3c95b0a libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Sat May 02 08:00:08 2015 +0000
+++ b/libexec/httpd/bozohttpd.c Sat May 02 11:35:48 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bozohttpd.c,v 1.63 2015/03/20 19:54:53 mrg Exp $       */
+/*     $NetBSD: bozohttpd.c,v 1.64 2015/05/02 11:35:48 mrg Exp $       */
 
 /*     $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $      */
 
@@ -109,7 +109,7 @@
 #define INDEX_HTML             "index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE                "bozohttpd/20150320"
+#define SERVER_SOFTWARE                "bozohttpd/20150501"
 #endif
 #ifndef DIRECT_ACCESS_FILE
 #define DIRECT_ACCESS_FILE     ".bzdirect"
@@ -1861,6 +1861,7 @@
        { 404,  "404 Not Found",        "This item has not been found", },
        { 408,  "408 Request Timeout",  "This request took too long", },
        { 417,  "417 Expectation Failed","Expectations not available", },
+       { 420,  "420 Enhance Your Calm","Chill, Winston", },
        { 500,  "500 Internal Error",   "An error occured on the server", },
        { 501,  "501 Not Implemented",  "This request is not available", },
        { 0,    NULL,                   NULL, },
diff -r 0bd0740f9dab -r ded2a3c95b0a libexec/httpd/bozohttpd.h
--- a/libexec/httpd/bozohttpd.h Sat May 02 08:00:08 2015 +0000
+++ b/libexec/httpd/bozohttpd.h Sat May 02 11:35:48 2015 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: bozohttpd.h,v 1.34 2014/11/21 08:58:28 shm Exp $       */
+/*     $NetBSD: bozohttpd.h,v 1.35 2015/05/02 11:35:48 mrg Exp $       */
 
 /*     $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $       */
 
 /*
- * Copyright (c) 1997-2014 Matthew R. Green
+ * Copyright (c) 1997-2015 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,6 @@
 
 typedef struct bozo_content_map_t {
        const char      *name;          /* postfix of file */
-       size_t           namelen;       /* length of postfix */
        const char      *type;          /* matching content-type */
        const char      *encoding;      /* matching content-encoding */
        const char      *encoding11;    /* matching content-encoding (HTTP/1.1) */
diff -r 0bd0740f9dab -r ded2a3c95b0a libexec/httpd/cgi-bozo.c
--- a/libexec/httpd/cgi-bozo.c  Sat May 02 08:00:08 2015 +0000
+++ b/libexec/httpd/cgi-bozo.c  Sat May 02 11:35:48 2015 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: cgi-bozo.c,v 1.26 2015/04/19 19:05:19 christos Exp $   */
+/*     $NetBSD: cgi-bozo.c,v 1.27 2015/05/02 11:35:48 mrg Exp $        */
 
 /*     $eterna: cgi-bozo.c,v 1.40 2011/11/18 09:21:15 mrg Exp $        */
 
 /*
- * Copyright (c) 1997-2014 Matthew R. Green
+ * Copyright (c) 1997-2015 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -515,7 +515,6 @@
 
        map = bozo_get_content_map(httpd, arg);
        map->name = arg;
-       map->namelen = strlen(map->name);
        map->type = map->encoding = map->encoding11 = NULL;
        map->cgihandler = cgihandler;
 }
diff -r 0bd0740f9dab -r ded2a3c95b0a libexec/httpd/content-bozo.c
--- a/libexec/httpd/content-bozo.c      Sat May 02 08:00:08 2015 +0000
+++ b/libexec/httpd/content-bozo.c      Sat May 02 11:35:48 2015 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: content-bozo.c,v 1.11 2014/12/13 19:30:04 mrg Exp $    */
+/*     $NetBSD: content-bozo.c,v 1.12 2015/05/02 11:35:48 mrg Exp $    */
 
 /*     $eterna: content-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $    */
 
 /*
- * Copyright (c) 1997-2014 Matthew R. Green
+ * Copyright (c) 1997-2015 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,143 +47,145 @@
  */
 
 static bozo_content_map_t static_content_map[] = {
-       { ".html",      5, "text/html",                 "",             "", NULL },
-       { ".htm",       4, "text/html",                 "",             "", NULL },
-       { ".gif",       4, "image/gif",                 "",             "", NULL },
-       { ".jpeg",      5, "image/jpeg",                "",             "", NULL },
-       { ".jpg",       4, "image/jpeg",                "",             "", NULL },
-       { ".jpe",       4, "image/jpeg",                "",             "", NULL },
-       { ".png",       4, "image/png",                 "",             "", NULL },
-       { ".mp3",       4, "audio/mpeg",                "",             "", NULL },
-       { ".css",       4, "text/css",                  "",             "", NULL },
-       { ".txt",       4, "text/plain",                "",             "", NULL },
-       { ".swf",       4, "application/x-shockwave-flash","",          "", NULL },
-       { ".dcr",       4, "application/x-director",    "",             "", NULL },
-       { ".pac",       4, "application/x-ns-proxy-autoconfig", "",     "", NULL },
-       { ".pa",        3, "application/x-ns-proxy-autoconfig", "",     "", NULL },
-       { ".tar",       4, "multipart/x-tar",           "",             "", NULL },
-       { ".gtar",      5, "multipart/x-gtar",          "",             "", NULL },
-       { ".tar.Z",     6, "multipart/x-tar",           "x-compress",   "compress", NULL },
-       { ".tar.gz",    7, "multipart/x-tar",           "x-gzip",       "gzip", NULL },
-       { ".taz",       4, "multipart/x-tar",           "x-gzip",       "gzip", NULL },
-       { ".tgz",       4, "multipart/x-tar",           "x-gzip",       "gzip", NULL },
-       { ".tar.z",     6, "multipart/x-tar",           "x-pack",       "x-pack", NULL },
-       { ".Z",         2, "application/x-compress",    "x-compress",   "compress", NULL },
-       { ".gz",        3, "application/x-gzip",        "x-gzip",       "gzip", NULL },
-       { ".z",         2, "unknown",                   "x-pack",       "x-pack", NULL },
-       { ".bz2",       4, "application/x-bzip2",       "x-bzip2",      "x-bzip2", NULL },
-       { ".ogg",       4, "application/x-ogg",         "",             "", NULL },
-       { ".mkv",       4, "video/x-matroska",          "",             "", NULL },
-       { ".xbel",      5, "text/xml",                  "",             "", NULL },
-       { ".xml",       4, "text/xml",                  "",             "", NULL },
-       { ".xsl",       4, "text/xml",                  "",             "", NULL },
-       { ".hqx",       4, "application/mac-binhex40",  "",             "", NULL },
-       { ".cpt",       4, "application/mac-compactpro","",             "", NULL },
-       { ".doc",       4, "application/msword",        "",             "", NULL },
-       { ".bin",       4, "application/octet-stream",  "",             "", NULL },
-       { ".dms",       4, "application/octet-stream",  "",             "", NULL },
-       { ".lha",       4, "application/octet-stream",  "",             "", NULL },
-       { ".lzh",       4, "application/octet-stream",  "",             "", NULL },
-       { ".exe",       4, "application/octet-stream",  "",             "", NULL },
-       { ".class",     6, "application/octet-stream",  "",             "", NULL },
-       { ".oda",       4, "application/oda",           "",             "", NULL },
-       { ".pdf",       4, "application/pdf",           "",             "", NULL },
-       { ".ai",        3, "application/postscript",    "",             "", NULL },
-       { ".eps",       4, "application/postscript",    "",             "", NULL },
-       { ".ps",        3, "application/postscript",    "",             "", NULL },
-       { ".ppt",       4, "application/powerpoint",    "",             "", NULL },
-       { ".rtf",       4, "application/rtf",           "",             "", NULL },
-       { ".bcpio",     6, "application/x-bcpio",       "",             "", NULL },
-       { ".torrent",   8, "application/x-bittorrent",  "",             "", NULL },
-       { ".vcd",       4, "application/x-cdlink",      "",             "", NULL },
-       { ".cpio",      5, "application/x-cpio",        "",             "", NULL },
-       { ".csh",       4, "application/x-csh",         "",             "", NULL },
-       { ".dir",       4, "application/x-director",    "",             "", NULL },
-       { ".dxr",       4, "application/x-director",    "",             "", NULL },
-       { ".dvi",       4, "application/x-dvi",         "",             "", NULL },
-       { ".hdf",       4, "application/x-hdf",         "",             "", NULL },
-       { ".cgi",       4, "application/x-httpd-cgi",   "",             "", NULL },
-       { ".skp",       4, "application/x-koan",        "",             "", NULL },
-       { ".skd",       4, "application/x-koan",        "",             "", NULL },
-       { ".skt",       4, "application/x-koan",        "",             "", NULL },
-       { ".skm",       4, "application/x-koan",        "",             "", NULL },
-       { ".latex",     6, "application/x-latex",       "",             "", NULL },
-       { ".mif",       4, "application/x-mif",         "",             "", NULL },
-       { ".nc",        3, "application/x-netcdf",      "",             "", NULL },
-       { ".cdf",       4, "application/x-netcdf",      "",             "", NULL },
-       { ".patch",     6, "application/x-patch",       "",             "", NULL },
-       { ".sh",        3, "application/x-sh",          "",             "", NULL },
-       { ".shar",      5, "application/x-shar",        "",             "", NULL },
-       { ".sit",       4, "application/x-stuffit",     "",             "", NULL },
-       { ".sv4cpio",   8, "application/x-sv4cpio",     "",             "", NULL },
-       { ".sv4crc",    7, "application/x-sv4crc",      "",             "", NULL },
-       { ".tar",       4, "application/x-tar",         "",             "", NULL },
-       { ".tcl",       4, "application/x-tcl",         "",             "", NULL },
-       { ".tex",       4, "application/x-tex",         "",             "", NULL },
-       { ".texinfo",   8, "application/x-texinfo",     "",             "", NULL },
-       { ".texi",      5, "application/x-texinfo",     "",             "", NULL },
-       { ".t",         2, "application/x-troff",       "",             "", NULL },
-       { ".tr",        3, "application/x-troff",       "",             "", NULL },
-       { ".roff",      5, "application/x-troff",       "",             "", NULL },
-       { ".man",       4, "application/x-troff-man",   "",             "", NULL },
-       { ".me",        3, "application/x-troff-me",    "",             "", NULL },
-       { ".ms",        3, "application/x-troff-ms",    "",             "", NULL },
-       { ".ustar",     6, "application/x-ustar",       "",             "", NULL },
-       { ".src",       4, "application/x-wais-source", "",             "", NULL },
-       { ".zip",       4, "application/zip",           "",             "", NULL },
-       { ".au",        3, "audio/basic",               "",             "", NULL },
-       { ".snd",       4, "audio/basic",               "",             "", NULL },
-       { ".mpga",      5, "audio/mpeg",                "",             "", NULL },
-       { ".mp2",       4, "audio/mpeg",                "",             "", NULL },
-       { ".aif",       4, "audio/x-aiff",              "",             "", NULL },
-       { ".aiff",      5, "audio/x-aiff",              "",             "", NULL },
-       { ".aifc",      5, "audio/x-aiff",              "",             "", NULL },
-       { ".ram",       4, "audio/x-pn-realaudio",      "",             "", NULL },
-       { ".rpm",       4, "audio/x-pn-realaudio-plugin","",            "", NULL },
-       { ".ra",        3, "audio/x-realaudio",         "",             "", NULL },
-       { ".wav",       4, "audio/x-wav",               "",             "", NULL },
-       { ".pdb",       4, "chemical/x-pdb",            "",             "", NULL },
-       { ".xyz",       4, "chemical/x-pdb",            "",             "", NULL },
-       { ".ief",       4, "image/ief",                 "",             "", NULL },
-       { ".tiff",      5, "image/tiff",                "",             "", NULL },
-       { ".tif",       4, "image/tiff",                "",             "", NULL },
-       { ".ras",       4, "image/x-cmu-raster",        "",             "", NULL },
-       { ".pnm",       4, "image/x-portable-anymap",   "",             "", NULL },
-       { ".pbm",       4, "image/x-portable-bitmap",   "",             "", NULL },
-       { ".pgm",       4, "image/x-portable-graymap",  "",             "", NULL },
-       { ".ppm",       4, "image/x-portable-pixmap",   "",             "", NULL },
-       { ".rgb",       4, "image/x-rgb",               "",             "", NULL },
-       { ".xbm",       4, "image/x-xbitmap",           "",             "", NULL },
-       { ".xpm",       4, "image/x-xpixmap",           "",             "", NULL },
-       { ".xwd",       4, "image/x-xwindowdump",       "",             "", NULL },
-       { ".rtx",       4, "text/richtext",             "",             "", NULL },
-       { ".tsv",       4, "text/tab-separated-values", "",             "", NULL },
-       { ".etx",       4, "text/x-setext",             "",             "", NULL },
-       { ".sgml",      5, "text/x-sgml",               "",             "", NULL },
-       { ".sgm",       4, "text/x-sgml",               "",             "", NULL },
-       { ".mpeg",      5, "video/mpeg",                "",             "", NULL },
-       { ".mpg",       4, "video/mpeg",                "",             "", NULL },
-       { ".mpe",       4, "video/mpeg",                "",             "", NULL },
-       { ".ts",        4, "video/mpeg",                "",             "", NULL },
-       { ".vob",       4, "video/mpeg",                "",             "", NULL },
-       { ".mp4",       4, "video/mp4",                 "",             "", NULL },
-       { ".qt",        3, "video/quicktime",           "",             "", NULL },
-       { ".mov",       4, "video/quicktime",           "",             "", NULL },
-       { ".avi",       4, "video/x-msvideo",           "",             "", NULL },
-       { ".movie",     6, "video/x-sgi-movie",         "",             "", NULL },
-       { ".ice",       4, "x-conference/x-cooltalk",   "",             "", NULL },
-       { ".wrl",       4, "x-world/x-vrml",            "",             "", NULL },
-       { ".vrml",      5, "x-world/x-vrml",            "",             "", NULL },
-       { ".svg",       5, "image/svg+xml",             "",             "", NULL },
-       { NULL,         0, NULL,                NULL,           NULL, NULL }
+       { ".html",      "text/html",                    "",             "", NULL },
+       { ".htm",       "text/html",                    "",             "", NULL },
+       { ".gif",       "image/gif",                    "",             "", NULL },
+       { ".jpeg",      "image/jpeg",                   "",             "", NULL },
+       { ".jpg",       "image/jpeg",                   "",             "", NULL },
+       { ".jpe",       "image/jpeg",                   "",             "", NULL },
+       { ".png",       "image/png",                    "",             "", NULL },
+       { ".mp3",       "audio/mpeg",                   "",             "", NULL },
+       { ".css",       "text/css",                     "",             "", NULL },
+       { ".txt",       "text/plain",                   "",             "", NULL },
+       { ".swf",       "application/x-shockwave-flash","",             "", NULL },
+       { ".dcr",       "application/x-director",       "",             "", NULL },
+       { ".pac",       "application/x-ns-proxy-autoconfig", "",        "", NULL },
+       { ".pa",        "application/x-ns-proxy-autoconfig", "",        "", NULL },
+       { ".tar",       "multipart/x-tar",              "",             "", NULL },
+       { ".gtar",      "multipart/x-gtar",             "",             "", NULL },
+       { ".tar.Z",     "multipart/x-tar",              "x-compress",   "compress", NULL },
+       { ".tar.gz",    "multipart/x-tar",              "x-gzip",       "gzip", NULL },
+       { ".taz",       "multipart/x-tar",              "x-gzip",       "gzip", NULL },
+       { ".tgz",       "multipart/x-tar",              "x-gzip",       "gzip", NULL },
+       { ".tar.z",     "multipart/x-tar",              "x-pack",       "x-pack", NULL },
+       { ".Z",         "application/x-compress",       "x-compress",   "compress", NULL },
+       { ".gz",        "application/x-gzip",           "x-gzip",       "gzip", NULL },
+       { ".z",         "unknown",                      "x-pack",       "x-pack", NULL },
+       { ".bz2",       "application/x-bzip2",          "x-bzip2",      "x-bzip2", NULL },
+       { ".ogg",       "application/x-ogg",            "",             "", NULL },
+       { ".mkv",       "video/x-matroska",             "",             "", NULL },
+       { ".xbel",      "text/xml",                     "",             "", NULL },
+       { ".xml",       "text/xml",                     "",             "", NULL },
+       { ".xsl",       "text/xml",                     "",             "", NULL },
+       { ".hqx",       "application/mac-binhex40",     "",             "", NULL },
+       { ".cpt",       "application/mac-compactpro",   "",             "", NULL },
+       { ".doc",       "application/msword",           "",             "", NULL },
+       { ".bin",       "application/octet-stream",     "",             "", NULL },
+       { ".dms",       "application/octet-stream",     "",             "", NULL },
+       { ".lha",       "application/octet-stream",     "",             "", NULL },
+       { ".lzh",       "application/octet-stream",     "",             "", NULL },
+       { ".exe",       "application/octet-stream",     "",             "", NULL },
+       { ".class",     "application/octet-stream",     "",             "", NULL },
+       { ".oda",       "application/oda",              "",             "", NULL },
+       { ".pdf",       "application/pdf",              "",             "", NULL },
+       { ".ai",        "application/postscript",       "",             "", NULL },
+       { ".eps",       "application/postscript",       "",             "", NULL },
+       { ".ps",        "application/postscript",       "",             "", NULL },
+       { ".ppt",       "application/powerpoint",       "",             "", NULL },
+       { ".rtf",       "application/rtf",              "",             "", NULL },
+       { ".bcpio",     "application/x-bcpio",          "",             "", NULL },
+       { ".torrent",   "application/x-bittorrent",     "",             "", NULL },
+       { ".vcd",       "application/x-cdlink",         "",             "", NULL },
+       { ".cpio",      "application/x-cpio",           "",             "", NULL },
+       { ".csh",       "application/x-csh",            "",             "", NULL },
+       { ".dir",       "application/x-director",       "",             "", NULL },
+       { ".dxr",       "application/x-director",       "",             "", NULL },



Home | Main Index | Thread Index | Old Index