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
cddf590e
Commit
cddf590e
authored
Aug 01, 2013
by
Joshua Bussdieker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error handling and cleanup match loop.
parent
d7018394
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
24 deletions
+35
-24
cache_key.c
bin/varnishd/cache/cache_key.c
+35
-24
No files found.
bin/varnishd/cache/cache_key.c
View file @
cddf590e
...
...
@@ -257,14 +257,18 @@ KEY_Create(struct busyobj *bo, struct vsb **psb)
int
size
;
while
(
read
=
enum_matchers
(
q
,
&
type
,
&
match
,
&
size
))
{
if
(
read
<
0
)
{
// TODO: Cleanup allocations
VSLb
(
bo
->
vsl
,
SLT_Error
,
"Malformed Key header modifier"
);
error
=
1
;
return
-
1
;
break
;
}
else
{
VSB_printf
(
sbm
,
"%c%.*s%c"
,
type
,
size
,
match
,
0
);
q
+=
read
;
}
VSB_printf
(
sbm
,
"%c%.*s%c"
,
type
,
size
,
match
,
0
);
q
+=
read
;
}
if
(
error
==
1
)
break
;
AZ
(
VSB_finish
(
sbm
));
l
=
VSB_len
(
sbm
);
e
=
h
;
...
...
@@ -312,6 +316,7 @@ KEY_Create(struct busyobj *bo, struct vsb **psb)
if
(
error
)
{
VSB_delete
(
sbh
);
VSB_delete
(
sbm
);
VSB_delete
(
sb
);
return
(
-
1
);
}
...
...
@@ -320,9 +325,11 @@ KEY_Create(struct busyobj *bo, struct vsb **psb)
VSB_printf
(
sb
,
"%c%c%c%c"
,
0xff
,
0xff
,
0
,
0
);
VSB_delete
(
sbh
);
VSB_delete
(
sbm
);
AZ
(
VSB_finish
(
sb
));
if
(
KEY_Match
(
bo
->
bereq
,
VSB_data
(
sb
))
==
0
)
{
VSLb
(
bo
->
vsl
,
SLT_Error
,
"Cache key doesn't match request"
);
return
-
1
;
}
...
...
@@ -384,7 +391,7 @@ KEY_Match(struct http *http, const uint8_t *key)
}
else
if
(
key
[
2
]
==
1
)
{
char
*
e
;
unsigned
l
=
vbe16dec
(
key
);
int
not_flag
=
1
;
int
not_flag
=
0
;
int
case_flag
=
0
;
i
=
http_GetHdr
(
http
,
(
const
char
*
)(
key
+
3
),
&
h
);
...
...
@@ -396,27 +403,31 @@ KEY_Match(struct http *http, const uint8_t *key)
const
char
*
matcher
=
key
+
4
+
key
[
3
]
+
1
;
while
(
*
matcher
!=
0
&&
*
matcher
!=
-
1
)
{
if
(
*
matcher
==
M_WORD
)
{
if
(
word_matcher
(
matcher
+
1
,
h
,
strlen
(
matcher
+
1
),
case_flag
)
^
not_flag
)
result
=
0
;
matcher
+=
strlen
(
matcher
)
+
1
;
}
else
if
(
*
matcher
==
M_SUBSTRING
)
{
if
(
substring_matcher
(
matcher
+
1
,
h
,
strlen
(
matcher
+
1
),
case_flag
)
^
not_flag
)
result
=
0
;
matcher
+=
strlen
(
matcher
)
+
1
;
}
else
if
(
*
matcher
==
M_BEGINNING
)
{
if
(
beginning_substring_matcher
(
matcher
+
1
,
h
,
strlen
(
matcher
+
1
),
case_flag
)
^
not_flag
)
char
*
m
=
matcher
+
1
;
switch
(
matcher
[
0
])
{
case
M_WORD
:
if
(
!
word_matcher
(
m
,
h
,
strlen
(
m
),
case_flag
)
^
not_flag
)
result
=
0
;
break
;
case
M_SUBSTRING
:
if
(
!
substring_matcher
(
m
,
h
,
strlen
(
m
),
case_flag
)
^
not_flag
)
result
=
0
;
break
;
case
M_BEGINNING
:
if
(
!
beginning_substring_matcher
(
m
,
h
,
strlen
(
m
),
case_flag
)
^
not_flag
)
result
=
0
;
break
;
case
M_CASE
:
case_flag
=
1
;
break
;
case
M_NOT
:
not_flag
=
1
;
break
;
default:
result
=
0
;
matcher
+=
strlen
(
matcher
)
+
1
;
}
else
if
(
*
matcher
==
M_CASE
)
{
case_flag
=
1
;
matcher
+=
strlen
(
matcher
)
+
1
;
}
else
if
(
*
matcher
==
M_NOT
)
{
not_flag
=
0
;
matcher
+=
strlen
(
matcher
)
+
1
;
}
else
{
result
=
0
;
break
;
}
matcher
+=
strlen
(
m
)
+
2
;
}
}
...
...
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