Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
8aa94940
Commit
8aa94940
authored
Mar 31, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't assume esi-spec lengths match up with storage segments.
parent
40e09c27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
34 deletions
+64
-34
cache_esi_deliver.c
bin/varnishd/cache_esi_deliver.c
+64
-34
No files found.
bin/varnishd/cache_esi_deliver.c
View file @
8aa94940
...
...
@@ -225,7 +225,7 @@ ESI_Deliver(struct sess *sp)
struct
storage
*
st
;
uint8_t
*
p
,
*
e
,
*
q
,
*
r
;
unsigned
off
;
ssize_t
l
,
l_icrc
=
0
;
ssize_t
l
,
l
2
,
l
_icrc
=
0
;
uint32_t
icrc
=
0
;
uint8_t
tailbuf
[
8
+
5
];
int
isgzip
;
...
...
@@ -291,7 +291,6 @@ ESI_Deliver(struct sess *sp)
case
VEC_V2
:
case
VEC_V8
:
l
=
ved_decode_len
(
&
p
);
r
=
p
;
if
(
isgzip
)
{
assert
(
*
p
==
VEC_C1
||
*
p
==
VEC_C2
||
*
p
==
VEC_C8
);
...
...
@@ -299,45 +298,76 @@ ESI_Deliver(struct sess *sp)
icrc
=
vbe32dec
(
p
);
p
+=
4
;
}
if
(
sp
->
wrk
->
gzip_resp
&&
isgzip
)
{
/*
* We have a gzip'ed VEC and delivers a
* gzip'ed ESI response.
*/
sp
->
wrk
->
crc
=
crc32_combine
(
sp
->
wrk
->
crc
,
icrc
,
l_icrc
);
sp
->
wrk
->
l_crc
+=
l_icrc
;
WRW_Write
(
sp
->
wrk
,
st
->
ptr
+
off
,
l
);
}
else
if
(
sp
->
wrk
->
gzip_resp
)
{
/*
* A gzip'ed ESI response, but the VEC was
* not gzip'ed.
*/
ved_pretend_gzip
(
sp
,
st
->
ptr
+
off
,
l
);
off
+=
l
;
}
else
if
(
isgzip
)
{
/*
* A gzip'ed VEC, but ungzip'ed ESI response
*/
AN
(
vgz
);
i
=
VGZ_WrwGunzip
(
sp
,
vgz
,
st
->
ptr
+
off
,
l
,
obuf
,
sizeof
obuf
,
&
obufl
);
assert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
}
else
{
/*
* Ungzip'ed VEC, ungzip'ed ESI response
*/
WRW_Write
(
sp
->
wrk
,
st
->
ptr
+
off
,
l
);
/*
* There is no guarantee that the 'l' bytes are all
* in the same storage segment, so loop over storage
* until we have processed them all.
*/
while
(
l
>
0
)
{
l2
=
l
;
if
(
l2
>
st
->
len
-
off
)
l2
=
st
->
len
-
off
;
l
-=
l2
;
if
(
sp
->
wrk
->
gzip_resp
&&
isgzip
)
{
/*
* We have a gzip'ed VEC and delivers
* a gzip'ed ESI response.
*/
sp
->
wrk
->
crc
=
crc32_combine
(
sp
->
wrk
->
crc
,
icrc
,
l_icrc
);
sp
->
wrk
->
l_crc
+=
l_icrc
;
WRW_Write
(
sp
->
wrk
,
st
->
ptr
+
off
,
l2
);
}
else
if
(
sp
->
wrk
->
gzip_resp
)
{
/*
* A gzip'ed ESI response, but the VEC
* was not gzip'ed.
*/
ved_pretend_gzip
(
sp
,
st
->
ptr
+
off
,
l2
);
}
else
if
(
isgzip
)
{
/*
* A gzip'ed VEC, but ungzip'ed ESI
* response
*/
AN
(
vgz
);
i
=
VGZ_WrwGunzip
(
sp
,
vgz
,
st
->
ptr
+
off
,
l2
,
obuf
,
sizeof
obuf
,
&
obufl
);
assert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
}
else
{
/*
* Ungzip'ed VEC, ungzip'ed ESI response
*/
WRW_Write
(
sp
->
wrk
,
st
->
ptr
+
off
,
l2
);
}
off
+=
l2
;
if
(
off
==
st
->
len
)
{
st
=
VTAILQ_NEXT
(
st
,
list
);
off
=
0
;
}
}
off
+=
l
;
break
;
case
VEC_S1
:
case
VEC_S2
:
case
VEC_S8
:
l
=
ved_decode_len
(
&
p
);
Debug
(
"SKIP1(%d)
\n
"
,
(
int
)
l
);
off
+=
l
;
/*
* There is no guarantee that the 'l' bytes are all
* in the same storage segment, so loop over storage
* until we have processed them all.
*/
while
(
l
>
0
)
{
l2
=
l
;
if
(
l2
>
st
->
len
-
off
)
l2
=
st
->
len
-
off
;
l
-=
l2
;
off
+=
l2
;
if
(
off
==
st
->
len
)
{
st
=
VTAILQ_NEXT
(
st
,
list
);
off
=
0
;
}
}
break
;
case
VEC_INCL
:
p
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment