Imposed some limits on request parts.
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 30 Apr 2011 06:45:29 +0000 (08:45 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 30 Apr 2011 06:45:29 +0000 (08:45 +0200)
lib/req.c
src/htparser.c

index a3e7273..da8e3f0 100644 (file)
--- a/lib/req.c
+++ b/lib/req.c
@@ -106,12 +106,16 @@ int parseheaders(struct hthead *head, FILE *in)
 {
     int c, state;
     struct charbuf name, val;
+    size_t tsz;
     
     bufinit(name);
     bufinit(val);
     state = 0;
+    tsz = 0;
     while(1) {
        c = fgetc(in);
+       if(++tsz >= 65536)
+           goto fail;
     again:
        if(state == 0) {
            if(c == '\r') {
index 5179a25..1ed9175 100644 (file)
@@ -77,6 +77,8 @@ static struct hthead *parsereq(FILE *in)
            goto fail;
        } else {
            bufadd(method, c);
+           if(method.d >= 128)
+               goto fail;
        }
     }
     while(1) {
@@ -87,6 +89,8 @@ static struct hthead *parsereq(FILE *in)
            goto fail;
        } else {
            bufadd(url, c);
+           if(url.d >= 65536)
+               goto fail;
        }
     }
     while(1) {
@@ -98,6 +102,8 @@ static struct hthead *parsereq(FILE *in)
            goto fail;
        } else {
            bufadd(ver, c);
+           if(ver.d >= 128)
+               goto fail;
        }
     }
     bufadd(method, 0);