Commit 6350bfb4 authored by Per Buer's avatar Per Buer
parents 4fcd5b8f 1054aede
...@@ -627,6 +627,7 @@ void Fetch_Init(void); ...@@ -627,6 +627,7 @@ void Fetch_Init(void);
struct vgz; struct vgz;
struct vgz *VGZ_NewUngzip(const struct sess *sp, struct ws *tmp); struct vgz *VGZ_NewUngzip(const struct sess *sp, struct ws *tmp);
struct vgz *VGZ_NewGzip(const struct sess *sp, struct ws *tmp);
void VGZ_Ibuf(struct vgz *, const void *, ssize_t len); void VGZ_Ibuf(struct vgz *, const void *, ssize_t len);
int VGZ_IbufEmpty(struct vgz *vg); int VGZ_IbufEmpty(struct vgz *vg);
void VGZ_Obuf(struct vgz *, const void *, ssize_t len); void VGZ_Obuf(struct vgz *, const void *, ssize_t len);
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#define VEC_V1 (0x40 + 1) #define VEC_V1 (0x40 + 1)
#define VEC_V2 (0x40 + 2) #define VEC_V2 (0x40 + 2)
#define VEC_V8 (0x40 + 8) #define VEC_V8 (0x40 + 8)
#define VEC_C1 (0x50 + 1)
#define VEC_C2 (0x50 + 2)
#define VEC_C8 (0x50 + 8)
#define VEC_S1 (0x60 + 1) #define VEC_S1 (0x60 + 1)
#define VEC_S2 (0x60 + 2) #define VEC_S2 (0x60 + 2)
#define VEC_S8 (0x60 + 8) #define VEC_S8 (0x60 + 8)
......
...@@ -174,7 +174,7 @@ ESI_Deliver(struct sess *sp) ...@@ -174,7 +174,7 @@ ESI_Deliver(struct sess *sp)
struct storage *st; struct storage *st;
uint8_t *p, *e, *q, *r; uint8_t *p, *e, *q, *r;
unsigned off; unsigned off;
ssize_t l; ssize_t l, l_crc;
uint32_t crc, crc_ref; uint32_t crc, crc_ref;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
...@@ -192,6 +192,8 @@ ESI_Deliver(struct sess *sp) ...@@ -192,6 +192,8 @@ ESI_Deliver(struct sess *sp)
case VEC_V2: case VEC_V2:
case VEC_V8: case VEC_V8:
l = ved_decode_len(&p); l = ved_decode_len(&p);
assert(*p == VEC_C1 || *p == VEC_C2 || *p == VEC_C8);
l_crc = ved_decode_len(&p);
crc = vbe32dec(p); crc = vbe32dec(p);
p += 4; p += 4;
q = (void*)strchr((const char*)p, '\0'); q = (void*)strchr((const char*)p, '\0');
......
...@@ -280,6 +280,7 @@ vep_emit_verbatim(const struct vep_state *vep, ssize_t l) ...@@ -280,6 +280,7 @@ vep_emit_verbatim(const struct vep_state *vep, ssize_t l)
Debug("---> VERBATIM(%jd)\n", (intmax_t)l); Debug("---> VERBATIM(%jd)\n", (intmax_t)l);
} }
vep_emit_len(vep, l, VEC_V1, VEC_V2, VEC_V8); vep_emit_len(vep, l, VEC_V1, VEC_V2, VEC_V8);
vep_emit_len(vep, l, VEC_C1, VEC_C2, VEC_C8);
vbe32enc(buf, vep->crc); vbe32enc(buf, vep->crc);
vsb_bcat(vep->vsb, buf, sizeof buf); vsb_bcat(vep->vsb, buf, sizeof buf);
vsb_printf(vep->vsb, "%lx\r\n%c", l, 0); vsb_printf(vep->vsb, "%lx\r\n%c", l, 0);
......
...@@ -151,7 +151,7 @@ VGZ_NewUngzip(const struct sess *sp, struct ws *tmp) ...@@ -151,7 +151,7 @@ VGZ_NewUngzip(const struct sess *sp, struct ws *tmp)
return (vg); return (vg);
} }
static struct vgz * struct vgz *
VGZ_NewGzip(const struct sess *sp, struct ws *tmp) VGZ_NewGzip(const struct sess *sp, struct ws *tmp)
{ {
struct vgz *vg; struct vgz *vg;
...@@ -307,7 +307,7 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, size_t bytes) ...@@ -307,7 +307,7 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, size_t bytes)
struct storage *st; struct storage *st;
ssize_t l, w; ssize_t l, w;
int i = -100; int i = -100;
uint8_t ibuf[64*1024]; /* XXX size ? */ uint8_t ibuf[1024 * params->gzip_stack_buffer];
size_t dl; size_t dl;
const void *dp; const void *dp;
...@@ -406,7 +406,7 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, size_t bytes) ...@@ -406,7 +406,7 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, size_t bytes)
struct storage *st; struct storage *st;
ssize_t l, w; ssize_t l, w;
int i = -100; int i = -100;
uint8_t ibuf[64*1024]; /* XXX size ? */ uint8_t ibuf[1024 * params->gzip_stack_buffer];
size_t dl; size_t dl;
const void *dp; const void *dp;
......
...@@ -247,7 +247,7 @@ res_WriteGunzipObj(struct sess *sp) ...@@ -247,7 +247,7 @@ res_WriteGunzipObj(struct sess *sp)
struct vgz *vg; struct vgz *vg;
const void *dp; const void *dp;
char lenbuf[20]; char lenbuf[20];
char obuf[64*1024]; /* XXX: size? */ char obuf[1024 * params->gzip_stack_buffer];
size_t dl; size_t dl;
int i; int i;
......
...@@ -531,6 +531,8 @@ cmd_http_gunzip_body(CMD_ARGS) ...@@ -531,6 +531,8 @@ cmd_http_gunzip_body(CMD_ARGS)
memset(&vz, 0, sizeof vz); memset(&vz, 0, sizeof vz);
if (hp->body[0] != (char)0x1f || hp->body[1] != (char)0x8b)
vtc_log(hp->vl, 0, "Gunzip error: Body lacks gzip magics");
vz.next_in = TRUST_ME(hp->body); vz.next_in = TRUST_ME(hp->body);
vz.avail_in = hp->bodyl; vz.avail_in = hp->bodyl;
......
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