Commit 22ff9649 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Get better diagnostics on ESI-code string errors.

Related to: #1773
parent 15968233
...@@ -187,7 +187,7 @@ ved_include(struct req *preq, const char *src, const char *host, ...@@ -187,7 +187,7 @@ ved_include(struct req *preq, const char *src, const char *host,
#define Debug(fmt, ...) /**/ #define Debug(fmt, ...) /**/
static ssize_t static ssize_t
ved_decode_len(uint8_t **pp) ved_decode_len(struct req *req, uint8_t **pp)
{ {
uint8_t *p; uint8_t *p;
ssize_t l; ssize_t l;
...@@ -207,8 +207,9 @@ ved_decode_len(uint8_t **pp) ...@@ -207,8 +207,9 @@ ved_decode_len(uint8_t **pp)
p += 9; p += 9;
break; break;
default: default:
Debug("Illegal Length %d %d\n", *p, (*p & 15)); VSLb(req->vsl, SLT_Error,
INCOMPL(); "ESI-corruption: Illegal Length %d %d\n", *p, (*p & 15));
WRONG("ESI-codes: illegal length");
} }
*pp = p; *pp = p;
assert(l > 0); assert(l > 0);
...@@ -286,12 +287,16 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, ...@@ -286,12 +287,16 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv,
case VEC_V1: case VEC_V1:
case VEC_V2: case VEC_V2:
case VEC_V8: case VEC_V8:
ecx->l = ved_decode_len(&ecx->p); ecx->l = ved_decode_len(req, &ecx->p);
if (ecx->l < 0)
return (-1);
if (ecx->isgzip) { if (ecx->isgzip) {
assert(*ecx->p == VEC_C1 || assert(*ecx->p == VEC_C1 ||
*ecx->p == VEC_C2 || *ecx->p == VEC_C2 ||
*ecx->p == VEC_C8); *ecx->p == VEC_C8);
l = ved_decode_len(&ecx->p); l = ved_decode_len(req, &ecx->p);
if (l < 0)
return (-1);
icrc = vbe32dec(ecx->p); icrc = vbe32dec(ecx->p);
ecx->p += 4; ecx->p += 4;
if (ecx->isgzip) { if (ecx->isgzip) {
...@@ -305,7 +310,9 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, ...@@ -305,7 +310,9 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv,
case VEC_S1: case VEC_S1:
case VEC_S2: case VEC_S2:
case VEC_S8: case VEC_S8:
ecx->l = ved_decode_len(&ecx->p); ecx->l = ved_decode_len(req, &ecx->p);
if (ecx->l < 0)
return (-1);
Debug("SKIP1(%d)\n", (int)ecx->l); Debug("SKIP1(%d)\n", (int)ecx->l);
ecx->state = 4; ecx->state = 4;
break; break;
...@@ -327,8 +334,10 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, ...@@ -327,8 +334,10 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv,
ecx->p = r + 1; ecx->p = r + 1;
break; break;
default: default:
Debug("XXXX 0x%02x [%s]\n", *ecx->p, ecx->p); VSLb(req->vsl, SLT_Error,
INCOMPL(); "ESI corruption line %d 0x%02x [%s]\n",
__LINE__, *ecx->p, ecx->p);
WRONG("ESI-codes: Illegal code");
} }
break; break;
case 2: case 2:
......
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