summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-08-09 18:46:06 +0000
committerLaurent Bercot <ska@appnovation.com>2023-08-09 18:46:06 +0000
commit5bf49ff287df28f05943a3ef48e36c38917ed2a2 (patch)
tree95accb118fdb612415b441803d5ded4d2ab5551c /src
parentd2c2170ec527d8c5ad4829fe91135180ff6e36d2 (diff)
downloadtipidee-5bf49ff287df28f05943a3ef48e36c38917ed2a2.tar.xz
Fix arg checking in content-type and index_file directives
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/config/PARSING-config.txt2
-rw-r--r--src/config/lexparse.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/config/PARSING-config.txt b/src/config/PARSING-config.txt
index b1be2df..688d93c 100644
--- a/src/config/PARSING-config.txt
+++ b/src/config/PARSING-config.txt
@@ -1,6 +1,6 @@
global verbosity 1
global read_timeout 60000
-global index index.cgi index.html
+global index_file index.cgi index.html
content-type application/pdf .pdf
content-type text/plain .c .h .txt
diff --git a/src/config/lexparse.c b/src/config/lexparse.c
index f843f97..91743bb 100644
--- a/src/config/lexparse.c
+++ b/src/config/lexparse.c
@@ -100,8 +100,8 @@ static inline void parse_global (char const *s, size_t const *word, size_t n, md
{ .name = "write_timeout", .key = "G:write_timeout", .type = 0 }
} ;
struct globalkey_s *gl ;
- if (n != 2)
- strerr_dief8x(1, "too ", n > 2 ? "many" : "few", " arguments to directive ", "global", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
+ if (n < 2)
+ strerr_dief8x(1, "too ", "few", " arguments to directive ", "global", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
gl = bsearch(s + word[0], globalkeys, sizeof(globalkeys)/sizeof(struct globalkey_s), sizeof(struct globalkey_s), &globalkey_cmp) ;
if (!gl) strerr_dief6x(1, "unrecognized global setting ", s + word[0], " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
switch (gl->type)
@@ -110,7 +110,7 @@ static inline void parse_global (char const *s, size_t const *word, size_t n, md
{
char pack[4] ;
uint32_t u ;
- if (n != 2) strerr_dief7x(1, "too many", " arguments to global setting ", s + word[0], " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
+ if (n > 2) strerr_dief8x(1, "too ", "many", " arguments to global setting ", s + word[0], " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
if (!uint320_scan(s + word[1], &u))
strerr_dief6x(1, "invalid (non-numeric) value for global setting ", s + word[0], " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
uint32_pack_big(pack, u) ;
@@ -133,8 +133,8 @@ static inline void parse_global (char const *s, size_t const *word, size_t n, md
static inline void parse_contenttype (char const *s, size_t const *word, size_t n, mdt const *md)
{
char const *ct ;
- if (n != 3)
- strerr_dief8x(1, "too ", n > 3 ? "many" : "few", " arguments to directive ", "redirect", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
+ if (n < 2)
+ strerr_dief8x(1, "too ", "few", " arguments to directive ", "redirect", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
ct = s + *word++ ;
if (!strchr(ct, '/'))
strerr_dief6x(1, "Content-Type must include a slash, ", "check directive", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;