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
c394dfb7
Commit
c394dfb7
authored
Mar 18, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be able to detect parse error during processing of backend Vary
headers, and do 503 on parse error.
parent
d1bbd0b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
10 deletions
+43
-10
cache.h
bin/varnishd/cache/cache.h
+1
-1
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+17
-5
cache_vary.c
bin/varnishd/cache/cache_vary.c
+25
-4
No files found.
bin/varnishd/cache/cache.h
View file @
c394dfb7
...
...
@@ -1003,7 +1003,7 @@ void RES_BuildHttp(struct req *);
void
RES_WriteObj
(
struct
req
*
);
/* cache_vary.c */
struct
vsb
*
VRY_Create
(
struct
req
*
sp
,
const
struct
http
*
hp
);
int
VRY_Create
(
struct
req
*
req
,
const
struct
http
*
hp
,
struct
vsb
**
psb
);
int
VRY_Match
(
struct
req
*
,
const
uint8_t
*
vary
);
void
VRY_Validate
(
const
uint8_t
*
vary
);
void
VRY_Prep
(
struct
req
*
);
...
...
bin/varnishd/cache/cache_req_fsm.c
View file @
c394dfb7
...
...
@@ -572,12 +572,24 @@ cnt_fetchbody(struct worker *wrk, struct req *req)
/* Create Vary instructions */
if
(
req
->
objcore
->
objhead
!=
NULL
)
{
vary
=
VRY_Create
(
req
,
bo
->
beresp
);
if
(
vary
!=
NULL
)
{
varyl
=
VSB_len
(
vary
);
assert
(
varyl
>
0
);
vary
l
=
VRY_Create
(
req
,
bo
->
beresp
,
&
vary
);
if
(
vary
l
>
0
)
{
AN
(
vary
);
assert
(
varyl
==
VSB_len
(
vary
)
);
l
+=
varyl
;
}
}
else
if
(
varyl
<
0
)
{
/* Vary parse error */
AZ
(
vary
);
req
->
err_code
=
503
;
req
->
req_step
=
R_STP_ERROR
;
AZ
(
HSH_Deref
(
&
wrk
->
stats
,
req
->
objcore
,
NULL
));
req
->
objcore
=
NULL
;
VDI_CloseFd
(
&
bo
->
vbc
);
VBO_DerefBusyObj
(
wrk
,
&
req
->
busyobj
);
return
(
REQ_FSM_MORE
);
}
else
/* No vary */
AZ
(
vary
);
}
/*
...
...
bin/varnishd/cache/cache_vary.c
View file @
c394dfb7
...
...
@@ -61,16 +61,29 @@
#include "vct.h"
#include "vend.h"
struct
vsb
*
VRY_Create
(
struct
req
*
req
,
const
struct
http
*
hp
)
/**********************************************************************
* Create a Vary matching string from a Vary header
*
* Return value:
* <0: Parse error
* 0: No Vary header on object
* >0: Length of Vary matching string in *psb
*/
int
VRY_Create
(
struct
req
*
req
,
const
struct
http
*
hp
,
struct
vsb
**
psb
)
{
char
*
v
,
*
p
,
*
q
,
*
h
,
*
e
;
struct
vsb
*
sb
,
*
sbh
;
unsigned
l
;
int
error
=
0
;
AN
(
psb
);
AZ
(
*
psb
);
/* No Vary: header, no worries */
if
(
!
http_GetHdr
(
hp
,
H_Vary
,
&
v
))
return
(
NULL
);
return
(
0
);
/* For vary matching string */
sb
=
VSB_new_auto
();
...
...
@@ -125,12 +138,20 @@ VRY_Create(struct req *req, const struct http *hp)
xxxassert
(
*
q
==
','
);
p
=
q
;
}
if
(
error
)
{
VSB_delete
(
sbh
);
VSB_delete
(
sb
);
return
(
-
1
);
}
/* Terminate vary matching string */
VSB_printf
(
sb
,
"%c%c%c"
,
0xff
,
0xff
,
0
);
VSB_delete
(
sbh
);
AZ
(
VSB_finish
(
sb
));
return
(
sb
);
*
psb
=
sb
;
return
(
VSB_len
(
sb
));
}
/*
...
...
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