Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
7fd3aa3f
Commit
7fd3aa3f
authored
May 01, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't let the form of the argument to hash_data() leak into the
production of the hash-key. Fixes #1296
parent
80b3ecc0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
12 deletions
+43
-12
cache_hash.c
bin/varnishd/cache/cache_hash.c
+5
-10
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+7
-1
hash_slinger.h
bin/varnishd/hash/hash_slinger.h
+1
-1
r01296.vtc
bin/varnishtest/tests/r01296.vtc
+30
-0
No files found.
bin/varnishd/cache/cache_hash.c
View file @
7fd3aa3f
...
...
@@ -155,20 +155,15 @@ HSH_DeleteObjHead(struct dstat *ds, struct objhead *oh)
}
void
HSH_AddString
(
struct
req
*
req
,
const
char
*
str
)
HSH_AddString
(
const
struct
req
*
req
,
const
char
*
str
)
{
int
l
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
if
(
str
==
NULL
)
str
=
""
;
l
=
strlen
(
str
);
AN
(
req
->
sha256ctx
);
SHA256_Update
(
req
->
sha256ctx
,
str
,
l
);
SHA256_Update
(
req
->
sha256ctx
,
"#"
,
1
);
VSLb
(
req
->
vsl
,
SLT_Hash
,
"%s"
,
str
);
if
(
str
!=
NULL
)
SHA256_Update
(
req
->
sha256ctx
,
str
,
strlen
(
str
)
);
else
SHA256_Update
(
req
->
sha256ctx
,
&
str
,
sizeof
str
);
}
/*---------------------------------------------------------------------
...
...
bin/varnishd/cache/cache_vrt.c
View file @
7fd3aa3f
...
...
@@ -257,7 +257,7 @@ VRT_handling(const struct vrt_ctx *ctx, unsigned hand)
}
/*--------------------------------------------------------------------
*
Add an element to the array/list of hash bits.
*
Feed data into the hash calculation
*/
void
...
...
@@ -275,7 +275,13 @@ VRT_hashdata(const struct vrt_ctx *ctx, const char *str, ...)
if
(
p
==
vrt_magic_string_end
)
break
;
HSH_AddString
(
ctx
->
req
,
p
);
VSLb
(
ctx
->
vsl
,
SLT_Hash
,
"%s"
,
str
);
}
/*
* Add a 'field-separator' to make it more difficult to
* manipulate the hash.
*/
HSH_AddString
(
ctx
->
req
,
NULL
);
}
/*--------------------------------------------------------------------*/
...
...
bin/varnishd/hash/hash_slinger.h
View file @
7fd3aa3f
...
...
@@ -69,7 +69,7 @@ enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **,
void
HSH_Ref
(
struct
objcore
*
o
);
void
HSH_Drop
(
struct
worker
*
,
struct
object
**
);
void
HSH_Init
(
const
struct
hash_slinger
*
slinger
);
void
HSH_AddString
(
struct
req
*
,
const
char
*
str
);
void
HSH_AddString
(
const
struct
req
*
,
const
char
*
str
);
void
HSH_Insert
(
struct
worker
*
,
const
void
*
hash
,
struct
objcore
*
);
void
HSH_Purge
(
struct
req
*
,
struct
objhead
*
,
double
ttl
,
double
grace
);
void
HSH_config
(
const
char
*
h_arg
);
...
...
bin/varnishtest/tests/r01296.vtc
0 → 100644
View file @
7fd3aa3f
varnishtest "hash key depends on argument form to hash_data()"
server s1 {
rxreq
txresp -hdr "OK: yes"
rxreq
txresp -hdr "OK: no"
} -start
varnish v1 -vcl+backend {
sub vcl_hash {
if (req.http.foo == "1") {
hash_data("123");
} else {
hash_data("1" + req.http.foo + "3");
}
return (hash);
}
} -start
client c1 {
txreq -hdr "foo: 1"
rxresp
expect resp.http.ok == "yes"
txreq -hdr "foo: 2"
rxresp
expect resp.http.ok == "yes"
} -run
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