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
bf58f061
Commit
bf58f061
authored
May 06, 2013
by
Tollef Fog Heen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return an error on duplicated Host headers
parent
fddbe671
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_http.c
bin/varnishd/cache/cache_http.c
+1
-1
cache_http1_proto.c
bin/varnishd/cache/cache_http1_proto.c
+29
-0
No files found.
bin/varnishd/cache/cache.h
View file @
bf58f061
...
...
@@ -877,6 +877,7 @@ double http_GetHdrQ(const struct http *hp, const char *hdr, const char *field);
uint16_t
http_GetStatus
(
const
struct
http
*
hp
);
const
char
*
http_GetReq
(
const
struct
http
*
hp
);
int
http_HdrIs
(
const
struct
http
*
hp
,
const
char
*
hdr
,
const
char
*
val
);
int
http_IsHdr
(
const
txt
*
hh
,
const
char
*
hdr
);
enum
sess_close
http_DoConnection
(
const
struct
http
*
);
void
http_CopyHome
(
const
struct
http
*
hp
);
void
http_Unset
(
struct
http
*
hp
,
const
char
*
hdr
);
...
...
bin/varnishd/cache/cache_http.c
View file @
bf58f061
...
...
@@ -154,7 +154,7 @@ http_Teardown(struct http *hp)
/*--------------------------------------------------------------------*/
static
int
int
http_IsHdr
(
const
txt
*
hh
,
const
char
*
hdr
)
{
unsigned
l
;
...
...
bin/varnishd/cache/cache_http1_proto.c
View file @
bf58f061
...
...
@@ -374,6 +374,30 @@ htc_splitline(struct http *hp, const struct http_conn *htc, int req)
return
(
htc_dissect_hdrs
(
hp
,
p
,
htc
));
}
/*--------------------------------------------------------------------*/
static
int
htc_request_check_host_hdr
(
struct
http
*
hp
)
{
int
u
;
int
seen_host
=
0
;
for
(
u
=
HTTP_HDR_FIRST
;
u
<
hp
->
nhd
;
u
++
)
{
if
(
hp
->
hd
[
u
].
b
==
NULL
)
continue
;
AN
(
hp
->
hd
[
u
].
b
);
AN
(
hp
->
hd
[
u
].
e
);
if
(
http_IsHdr
(
&
hp
->
hd
[
u
],
H_Host
))
{
if
(
seen_host
)
{
VSLb
(
hp
->
vsl
,
SLT_Error
,
"Duplicated Host header"
);
return
(
400
);
}
seen_host
=
1
;
}
}
return
(
0
);
}
/*--------------------------------------------------------------------*/
static
void
...
...
@@ -412,6 +436,11 @@ HTTP1_DissectRequest(struct req *req)
}
htc_proto_ver
(
hp
);
retval
=
htc_request_check_host_hdr
(
hp
);
if
(
retval
!=
0
)
{
return
(
retval
);
}
/* RFC2616, section 5.2, point 1 */
if
(
!
strncasecmp
(
hp
->
hd
[
HTTP_HDR_URL
].
b
,
"http://"
,
7
))
{
b
=
e
=
hp
->
hd
[
HTTP_HDR_URL
].
b
+
7
;
...
...
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