Commit 6c9021d9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add an assert to ensure that our estimate of struct http size

matches the actual size later on.

Inspired by: #2298
parent 667256f1
......@@ -749,7 +749,7 @@ void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgz_ua_e);
/* cache_http.c */
unsigned HTTP_estimate(unsigned nhttp);
void HTTP_Copy(struct http *to, const struct http * const fm);
struct http *HTTP_create(void *p, uint16_t nhttp);
struct http *HTTP_create(void *p, uint16_t nhttp, unsigned);
const char *http_Status2Reason(unsigned, const char **);
unsigned http_EstimateWS(const struct http *fm, unsigned how);
void http_PutResponse(struct http *to, const char *proto, uint16_t status,
......
......@@ -101,17 +101,17 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req)
nhttp = (uint16_t)cache_param->http_max_hdr;
sz = HTTP_estimate(nhttp);
bo->bereq0 = HTTP_create(p, nhttp);
bo->bereq0 = HTTP_create(p, nhttp, sz);
p += sz;
p = (void*)PRNDUP(p);
assert(p < bo->end);
bo->bereq = HTTP_create(p, nhttp);
bo->bereq = HTTP_create(p, nhttp, sz);
p += sz;
p = (void*)PRNDUP(p);
assert(p < bo->end);
bo->beresp = HTTP_create(p, nhttp);
bo->beresp = HTTP_create(p, nhttp, sz);
p += sz;
p = (void*)PRNDUP(p);
assert(p < bo->end);
......
......@@ -147,7 +147,7 @@ HTTP_estimate(unsigned nhttp)
}
struct http *
HTTP_create(void *p, uint16_t nhttp)
HTTP_create(void *p, uint16_t nhttp, unsigned len)
{
struct http *hp;
......@@ -156,6 +156,7 @@ HTTP_create(void *p, uint16_t nhttp)
hp->hd = (void*)(hp + 1);
hp->shd = nhttp;
hp->hdf = (void*)(hp->hd + nhttp);
assert((unsigned char*)p + len == hp->hdf + nhttp);
return (hp);
}
......
......@@ -77,17 +77,17 @@ Req_New(const struct worker *wrk, struct sess *sp)
nhttp = (uint16_t)cache_param->http_max_hdr;
hl = HTTP_estimate(nhttp);
req->http = HTTP_create(p, nhttp);
req->http = HTTP_create(p, nhttp, hl);
p += hl;
p = (void*)PRNDUP(p);
assert(p < e);
req->http0 = HTTP_create(p, nhttp);
req->http0 = HTTP_create(p, nhttp, hl);
p += hl;
p = (void*)PRNDUP(p);
assert(p < e);
req->resp = HTTP_create(p, nhttp);
req->resp = HTTP_create(p, nhttp, hl);
p += hl;
p = (void*)PRNDUP(p);
assert(p < e);
......
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