Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
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
Nils Goroll
libvmod-re2
Commits
77005abd
Commit
77005abd
authored
Jun 05, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the WS_* interface to check for correct allocations.
parent
180037b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
19 deletions
+13
-19
vmod_re2.c
src/vmod_re2.c
+13
-19
No files found.
src/vmod_re2.c
View file @
77005abd
...
...
@@ -184,13 +184,6 @@ match(VRT_CTX, vre2 * restrict vre2, VCL_STRING restrict subject,
#undef ERR_PREFIX
static
inline
void
WS_Contains
(
struct
ws
*
const
restrict
ws
,
const
void
*
const
restrict
ptr
,
const
size_t
len
)
{
assert
((
char
*
)
ptr
>=
ws
->
s
&&
(
char
*
)(
ptr
+
len
)
<=
ws
->
e
);
}
#define ERR_PREFIX "backref %ld, fallback \"%.40s\": "
static
VCL_STRING
...
...
@@ -205,7 +198,7 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback, void * const groups,
if
(
groups
==
match_failed
)
return
fallback
;
WS_
Contains
(
ctx
->
ws
,
groups
,
(
ngroups
+
1
)
*
match_sz
);
WS_
Assert_Allocated
(
ctx
->
ws
,
groups
,
(
ngroups
+
1
)
*
match_sz
);
if
((
err
=
vre2_capture
(
groups
,
(
int
)
refnum
,
&
capture
,
&
len
))
!=
NULL
)
{
...
...
@@ -220,7 +213,7 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback, void * const groups,
if
(
len
==
0
)
return
""
;
WS_
Contains
(
ctx
->
ws
,
capture
,
len
);
WS_
Assert_Allocated
(
ctx
->
ws
,
capture
,
len
);
if
((
backref
=
WS_Copy
(
ctx
->
ws
,
capture
,
len
+
1
))
==
NULL
)
{
VERR
(
ctx
,
ERR_PREFIX
"insufficient workspace for backref"
,
refnum
,
fallback
);
...
...
@@ -391,7 +384,7 @@ vmod_regex_match(const struct vrt_ctx *ctx, struct vmod_re2_regex *re,
task_match
->
magic
=
TASK_MATCH_MAGIC
;
}
else
{
WS_
Contains
(
ctx
->
ws
,
task
->
priv
,
sizeof
(
*
task_match
));
WS_
Assert_Allocated
(
ctx
->
ws
,
task
->
priv
,
sizeof
(
*
task_match
));
CAST_OBJ
(
task_match
,
task
->
priv
,
TASK_MATCH_MAGIC
);
}
...
...
@@ -436,7 +429,7 @@ vmod_regex_backref(VRT_CTX, struct vmod_re2_regex *re, VCL_INT refnum,
re
->
vcl_name
,
refnum
,
fallback
);
return
fallback
;
}
WS_
Contains
(
ctx
->
ws
,
task
->
priv
,
sizeof
(
*
task_match
));
WS_
Assert_Allocated
(
ctx
->
ws
,
task
->
priv
,
sizeof
(
*
task_match
));
CAST_OBJ
(
task_match
,
task
->
priv
,
TASK_MATCH_MAGIC
);
return
backref
(
ctx
,
refnum
,
fallback
,
task_match
->
groups
,
re
->
ngroups
);
}
...
...
@@ -477,7 +470,7 @@ vmod_regex_namedref(VRT_CTX, struct vmod_re2_regex *re, VCL_STRING name,
re
->
vcl_name
,
name
,
fallback
);
return
fallback
;
}
WS_
Contains
(
ctx
->
ws
,
task
->
priv
,
sizeof
(
*
task_match
));
WS_
Assert_Allocated
(
ctx
->
ws
,
task
->
priv
,
sizeof
(
*
task_match
));
CAST_OBJ
(
task_match
,
task
->
priv
,
TASK_MATCH_MAGIC
);
return
namedref
(
ctx
,
re
->
vre2
,
name
,
fallback
,
task_match
->
groups
,
re
->
ngroups
);
...
...
@@ -705,7 +698,7 @@ vmod_set_match(VRT_CTX, struct vmod_re2_set *set, VCL_STRING subject)
task
->
magic
=
TASK_SET_MATCH_MAGIC
;
}
else
{
WS_
Contains
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task
));
WS_
Assert_Allocated
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task
));
CAST_OBJ
(
task
,
priv
->
priv
,
TASK_SET_MATCH_MAGIC
);
}
...
...
@@ -749,12 +742,13 @@ vmod_set_matched(VRT_CTX, struct vmod_re2_set *set, VCL_INT n)
set
->
vcl_name
,
n
);
return
0
;
}
WS_
Contains
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task
));
WS_
Assert_Allocated
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task
));
CAST_OBJ
(
task
,
priv
->
priv
,
TASK_SET_MATCH_MAGIC
);
if
(
task
->
nmatches
==
0
)
return
0
;
WS_Contains
(
ctx
->
ws
,
task
->
matches
,
task
->
nmatches
*
sizeof
(
int
));
WS_Assert_Allocated
(
ctx
->
ws
,
task
->
matches
,
task
->
nmatches
*
sizeof
(
int
));
n
--
;
for
(
unsigned
i
=
0
;
i
<
task
->
nmatches
;
i
++
)
if
(
task
->
matches
[
i
]
==
n
)
...
...
@@ -777,7 +771,7 @@ vmod_set_nmatches(VRT_CTX, struct vmod_re2_set *set)
set
->
vcl_name
);
return
0
;
}
WS_
Contains
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task
));
WS_
Assert_Allocated
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task
));
CAST_OBJ
(
task
,
priv
->
priv
,
TASK_SET_MATCH_MAGIC
);
return
task
->
nmatches
;
}
...
...
@@ -842,7 +836,7 @@ vmod_match(VRT_CTX, struct vmod_priv *priv, VCL_STRING pattern,
task_match
->
magic
=
TASK_MATCH_MAGIC
;
}
else
{
WS_
Contains
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task_match
));
WS_
Assert_Allocated
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task_match
));
CAST_OBJ
(
task_match
,
priv
->
priv
,
TASK_MATCH_MAGIC
);
}
task_match
->
ngroups
=
ngroups
;
...
...
@@ -877,7 +871,7 @@ vmod_backref(VRT_CTX, struct vmod_priv *priv, VCL_INT refnum,
return
fallback
;
}
WS_
Contains
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task_match
));
WS_
Assert_Allocated
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task_match
));
CAST_OBJ
(
task_match
,
priv
->
priv
,
TASK_MATCH_MAGIC
);
if
(
task_match
->
never_capture
)
{
...
...
@@ -920,7 +914,7 @@ vmod_namedref(VRT_CTX, struct vmod_priv *priv, VCL_STRING name,
return
fallback
;
}
WS_
Contains
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task_match
));
WS_
Assert_Allocated
(
ctx
->
ws
,
priv
->
priv
,
sizeof
(
*
task_match
));
CAST_OBJ
(
task_match
,
priv
->
priv
,
TASK_MATCH_MAGIC
);
if
(
task_match
->
never_capture
)
{
...
...
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