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
62ab6836
Commit
62ab6836
authored
Sep 22, 2011
by
Poul-Henning Kamp
Committed by
Tollef Fog Heen
Feb 24, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to set limits for VRE matching.
parent
0d77e838
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
9 deletions
+59
-9
cache_vrt_re.c
bin/varnishd/cache_vrt_re.c
+5
-3
heritage.h
bin/varnishd/heritage.h
+3
-0
mgt_param.c
bin/varnishd/mgt_param.c
+18
-0
vre.h
include/vre.h
+17
-1
vre.c
lib/libvarnish/vre.c
+13
-2
vsl.c
lib/libvarnishapi/vsl.c
+3
-3
No files found.
bin/varnishd/cache_vrt_re.c
View file @
62ab6836
...
...
@@ -76,7 +76,7 @@ VRT_re_match(const struct sess *sp, const char *s, void *re)
s
=
""
;
AN
(
re
);
t
=
re
;
i
=
VRE_exec
(
t
,
s
,
strlen
(
s
),
0
,
0
,
NULL
,
0
);
i
=
VRE_exec
(
t
,
s
,
strlen
(
s
),
0
,
0
,
NULL
,
0
,
&
params
->
vre_limits
);
if
(
i
>=
0
)
return
(
1
);
if
(
i
<
VRE_ERROR_NOMATCH
)
...
...
@@ -101,7 +101,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
str
=
""
;
t
=
re
;
memset
(
ovector
,
0
,
sizeof
(
ovector
));
i
=
VRE_exec
(
t
,
str
,
strlen
(
str
),
0
,
0
,
ovector
,
30
);
i
=
VRE_exec
(
t
,
str
,
strlen
(
str
),
0
,
0
,
ovector
,
30
,
&
params
->
vre_limits
);
/* If it didn't match, we can return the original string */
if
(
i
==
VRE_ERROR_NOMATCH
)
...
...
@@ -139,7 +140,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
if
(
!
all
)
break
;
memset
(
&
ovector
,
0
,
sizeof
(
ovector
));
i
=
VRE_exec
(
t
,
str
,
strlen
(
str
),
0
,
0
,
ovector
,
30
);
i
=
VRE_exec
(
t
,
str
,
strlen
(
str
),
0
,
0
,
ovector
,
30
,
&
params
->
vre_limits
);
if
(
i
<
VRE_ERROR_NOMATCH
)
{
WSP
(
sp
,
SLT_VCL_error
,
"Regexp matching returned %d"
,
i
);
...
...
bin/varnishd/heritage.h
View file @
62ab6836
...
...
@@ -30,6 +30,7 @@
*/
#include <pthread.h>
#include "vre.h"
struct
listen_sock
{
VTAILQ_ENTRY
(
listen_sock
)
list
;
...
...
@@ -211,6 +212,8 @@ struct params {
double
critbit_cooloff
;
double
shortlived
;
struct
vre_limits
vre_limits
;
};
/*
...
...
bin/varnishd/mgt_param.c
View file @
62ab6836
...
...
@@ -948,6 +948,24 @@ static const struct parspec input_parspec[] = {
"Unreferenced VCL objects result in error.
\n
"
,
0
,
"on"
,
"bool"
},
{
"pcre_match_limit"
,
tweak_uint
,
&
master
.
vre_limits
.
match
,
1
,
UINT_MAX
,
"The limit for the number of internal matching function"
" calls in a pcre_exec() execution."
,
0
,
"10000"
,
""
},
{
"pcre_match_limit_recursion"
,
tweak_uint
,
&
master
.
vre_limits
.
match_recursion
,
1
,
UINT_MAX
,
"The limit for the number of internal matching function"
" recursions in a pcre_exec() execution."
,
0
,
"10000"
,
""
},
{
NULL
,
NULL
,
NULL
}
};
...
...
include/vre.h
View file @
62ab6836
...
...
@@ -27,9 +27,21 @@
*
* Regular expression support
*
* We wrap PCRE in VRE to make to make it feasible to use something else
* without hunting down stuff through out the Varnish source code.
*
*/
#ifndef VRE_H_INCLUDED
#define VRE_H_INCLUDED
struct
vre
;
struct
vre_limits
{
unsigned
match
;
unsigned
match_recursion
;
};
typedef
struct
vre
vre_t
;
/* This maps to PCRE error codes */
...
...
@@ -39,5 +51,9 @@ typedef struct vre vre_t;
#define VRE_CASELESS 0x00000001
vre_t
*
VRE_compile
(
const
char
*
,
int
,
const
char
**
,
int
*
);
int
VRE_exec
(
const
vre_t
*
,
const
char
*
,
int
,
int
,
int
,
int
*
,
int
);
int
VRE_exec
(
const
vre_t
*
code
,
const
char
*
subject
,
int
length
,
int
startoffset
,
int
options
,
int
*
ovector
,
int
ovecsize
,
const
volatile
struct
vre_limits
*
lim
);
void
VRE_free
(
vre_t
**
);
#endif
/* VRE_H_INCLUDED */
lib/libvarnish/vre.c
View file @
62ab6836
...
...
@@ -27,6 +27,7 @@
*/
#include <pcre.h>
#include <string.h>
#include "libvarnish.h"
#include "miniobj.h"
...
...
@@ -58,17 +59,27 @@ VRE_compile(const char *pattern, int options,
int
VRE_exec
(
const
vre_t
*
code
,
const
char
*
subject
,
int
length
,
int
startoffset
,
int
options
,
int
*
ovector
,
int
ovecsize
)
int
startoffset
,
int
options
,
int
*
ovector
,
int
ovecsize
,
const
volatile
struct
vre_limits
*
lim
)
{
CHECK_OBJ_NOTNULL
(
code
,
VRE_MAGIC
);
int
ov
[
30
];
pcre_extra
extra
;
if
(
ovector
==
NULL
)
{
ovector
=
ov
;
ovecsize
=
sizeof
(
ov
)
/
sizeof
(
ov
[
0
]);
}
return
(
pcre_exec
(
code
->
re
,
NULL
,
subject
,
length
,
memset
(
&
extra
,
0
,
sizeof
extra
);
if
(
lim
!=
NULL
)
{
extra
.
match_limit
=
lim
->
match
;
extra
.
flags
|=
PCRE_EXTRA_MATCH_LIMIT
;
extra
.
match_limit_recursion
=
lim
->
match_recursion
;
extra
.
flags
|=
PCRE_EXTRA_MATCH_LIMIT_RECURSION
;
}
return
(
pcre_exec
(
code
->
re
,
&
extra
,
subject
,
length
,
startoffset
,
options
,
ovector
,
ovecsize
));
}
...
...
lib/libvarnishapi/vsl.c
View file @
62ab6836
...
...
@@ -258,13 +258,13 @@ VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *bits)
continue
;
if
(
vsl
->
regincl
!=
NULL
)
{
i
=
VRE_exec
(
vsl
->
regincl
,
VSL_DATA
(
p
),
VSL_LEN
(
p
),
0
,
0
,
NULL
,
0
);
0
,
0
,
NULL
,
0
,
NULL
);
if
(
i
==
VRE_ERROR_NOMATCH
)
continue
;
}
if
(
vsl
->
regexcl
!=
NULL
)
{
i
=
VRE_exec
(
vsl
->
regexcl
,
VSL_DATA
(
p
),
VSL_LEN
(
p
),
0
,
0
,
NULL
,
0
);
0
,
0
,
NULL
,
0
,
NULL
);
if
(
i
!=
VRE_ERROR_NOMATCH
)
continue
;
}
...
...
@@ -274,7 +274,7 @@ VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *bits)
VTAILQ_FOREACH
(
vrm
,
&
vsl
->
matchers
,
next
)
{
if
(
vrm
->
tag
==
t
)
{
i
=
VRE_exec
(
vrm
->
re
,
VSL_DATA
(
p
),
VSL_LEN
(
p
),
0
,
0
,
NULL
,
0
);
VSL_LEN
(
p
),
0
,
0
,
NULL
,
0
,
NULL
);
if
(
i
>=
0
)
*
bits
|=
(
uintmax_t
)
1
<<
j
;
}
...
...
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