Commit e833084a authored by Nils Goroll's avatar Nils Goroll

assert array bounds of mem, minor formatting changes

parent 0cc155eb
...@@ -194,8 +194,10 @@ http0_mem_ws_alloc(struct http0_mem *m) { ...@@ -194,8 +194,10 @@ http0_mem_ws_alloc(struct http0_mem *m) {
static struct ws * static struct ws *
http0_get_mem(struct sess *sp, struct http0_meta *meta) { http0_get_mem(struct sess *sp, struct http0_meta *meta) {
struct ws *ws; struct ws *ws;
struct http0_mem *m = &meta->mem[sp->id]; struct http0_mem *m;
assert(sp->id < meta->nmem);
m = &meta->mem[sp->id];
CHECK_OBJ_NOTNULL(m, VMOD_HTTP0_MEM_MAGIC); CHECK_OBJ_NOTNULL(m, VMOD_HTTP0_MEM_MAGIC);
if (m->ws[0].s) { if (m->ws[0].s) {
...@@ -244,10 +246,10 @@ vesico_cookie_lookup(struct cookiehead *cookies, const txt name) { ...@@ -244,10 +246,10 @@ vesico_cookie_lookup(struct cookiehead *cookies, const txt name) {
assert(l); assert(l);
VSTAILQ_FOREACH(c, cookies, list) { VSTAILQ_FOREACH(c, cookies, list) {
if (Tlen(c->name) != l)
continue;
if (! c->valid) if (! c->valid)
continue; continue;
if (Tlen(c->name) != l)
continue;
if (strncmp(c->name.b, name.b, l) == 0) if (strncmp(c->name.b, name.b, l) == 0)
return c; return c;
} }
...@@ -315,6 +317,7 @@ vesico_analyze_cookie_header(struct sess *sp, const txt hdr, ...@@ -315,6 +317,7 @@ vesico_analyze_cookie_header(struct sess *sp, const txt hdr,
if (! Tlen(c->name)) if (! Tlen(c->name))
goto cookie_invalid; goto cookie_invalid;
if (! Tlen(c->value)) if (! Tlen(c->value))
goto cookie_invalid; goto cookie_invalid;
...@@ -370,7 +373,7 @@ vesico_write_cookie_hdr(struct sess *sp, struct http0_meta *meta, struct http *h ...@@ -370,7 +373,7 @@ vesico_write_cookie_hdr(struct sess *sp, struct http0_meta *meta, struct http *h
return "new cookies: not even the header name fits"; return "new cookies: not even the header name fits";
} }
memcpy(b, H_COOKIE + 1, *H_COOKIE); memcpy(b, H_COOKIE + 1, *H_COOKIE);
b += *H_COOKIE; b += *H_COOKIE;
*b++ = ' '; *b++ = ' ';
VSTAILQ_FOREACH(c, cookies, list) { VSTAILQ_FOREACH(c, cookies, list) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment