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
0060ee94
Commit
0060ee94
authored
May 17, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Found a sneaky way to tests VCC's vmod-tasting code.
parent
f4f41c51
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
125 additions
and
21 deletions
+125
-21
m00003.vtc
bin/varnishtest/tests/m00003.vtc
+33
-1
vcc_compile.c
lib/libvcc/vcc_compile.c
+1
-0
vcc_compile.h
lib/libvcc/vcc_compile.h
+1
-0
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+36
-19
Makefile.am
lib/libvmod_debug/Makefile.am
+9
-0
flint.lnt
lib/libvmod_debug/flint.lnt
+3
-0
vmod_debug.c
lib/libvmod_debug/vmod_debug.c
+42
-1
No files found.
bin/varnishtest/tests/m00003.vtc
View file @
0060ee94
...
...
@@ -14,7 +14,7 @@ varnish v1 -arg "-pvmod_path=${topbuild}/lib/libvmod_std/.libs/" \
varnish v1 -cliok "param.set vmod_path /nonexistent"
varnish v1 -errvcl {Could not
loa
d VMOD std} {
varnish v1 -errvcl {Could not
fin
d VMOD std} {
import std;
}
...
...
@@ -23,3 +23,35 @@ varnish v1 -cliok "param.set vmod_path ${topbuild}/lib/libvmod_std/.libs/"
varnish v1 -vcl+backend {
import std;
}
varnish v1 -cliok "param.set vmod_path ${tmpdir}"
shell "true > ${tmpdir}/libvmod_wrong.so"
varnish v1 -errvcl {Could not open VMOD wrong} {
import wrong;
}
shell "cp ${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so ${tmpdir}/libvmod_wrong.so"
varnish v1 -errvcl {Malformed VMOD wrong} {
import wrong;
}
varnish v1 -errvcl {Incompatible VMOD wrong0} {
import wrong0 from "${tmpdir}/libvmod_wrong.so";
}
varnish v1 -errvcl {Incompatible VMOD wrong1} {
import wrong1 from "${tmpdir}/libvmod_wrong.so";
}
varnish v1 -errvcl {Mangled VMOD wrong2} {
import wrong2 from "${tmpdir}/libvmod_wrong.so";
}
varnish v1 -errvcl {Wrong file for VMOD wrong3} {
import wrong3 from "${tmpdir}/libvmod_wrong.so";
}
shell "rm -f ${tmpdir}/libvmod_wrong.so"
lib/libvcc/vcc_compile.c
View file @
0060ee94
...
...
@@ -769,6 +769,7 @@ VCC_New(void)
VTAILQ_INIT
(
&
tl
->
sources
);
VTAILQ_INIT
(
&
tl
->
procs
);
VTAILQ_INIT
(
&
tl
->
sym_objects
);
VTAILQ_INIT
(
&
tl
->
sym_vmods
);
tl
->
nsources
=
0
;
...
...
lib/libvcc/vcc_compile.h
View file @
0060ee94
...
...
@@ -258,6 +258,7 @@ struct vcc {
const
char
*
default_probe
;
VTAILQ_HEAD
(,
symbol
)
sym_objects
;
VTAILQ_HEAD
(,
symbol
)
sym_vmods
;
unsigned
unique
;
unsigned
vmod_count
;
...
...
lib/libvcc/vcc_vmod.c
View file @
0060ee94
...
...
@@ -40,19 +40,26 @@
#include "vmod_abi.h"
#include "vsb.h"
struct
vmod_open
{
unsigned
magic
;
#define VMOD_OPEN_MAGIC 0x9995b1f3
void
*
hdl
;
const
char
*
err
;
};
static
int
vcc_path_dlopen
(
void
*
priv
,
const
char
*
fn
)
{
void
*
hdl
,
**
p
p
;
struct
vmod_open
*
vo
p
;
AN
(
priv
);
CAST_OBJ_NOTNULL
(
vop
,
priv
,
VMOD_OPEN_MAGIC
);
AN
(
fn
);
hdl
=
dlopen
(
fn
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
hdl
==
NULL
)
vop
->
hdl
=
dlopen
(
fn
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
vop
->
hdl
==
NULL
)
{
vop
->
err
=
dlerror
();
return
(
-
1
);
pp
=
priv
;
*
pp
=
hdl
;
}
return
(
0
);
}
...
...
@@ -156,7 +163,6 @@ vcc_json_wildcard(struct vcc *tl, struct symbol *msym, struct symbol *tsym)
void
vcc_ParseImport
(
struct
vcc
*
tl
)
{
void
*
hdl
;
char
fn
[
1024
],
*
fnp
,
*
fnpx
;
char
buf
[
256
];
const
char
*
p
;
...
...
@@ -166,14 +172,17 @@ vcc_ParseImport(struct vcc *tl)
const
struct
vmod_data
*
vmd
;
struct
vjsn
*
vj
;
int
again
=
0
;
struct
vmod_open
vop
[
1
];
INIT_OBJ
(
vop
,
VMOD_OPEN_MAGIC
);
t1
=
tl
->
t
;
SkipToken
(
tl
,
ID
);
/* "import" */
ExpectErr
(
tl
,
ID
);
mod
=
tl
->
t
;
msym
=
VCC_SymbolGet
(
tl
,
SYM_NONE
,
SYMTAB_NOERR
,
XREF_NONE
);
vcc_NextToken
(
tl
);
msym
=
VCC_SymbolGetTok
(
tl
,
SYM_NONE
,
SYMTAB_NOERR
,
XREF_NONE
,
mod
);
if
(
msym
!=
NULL
&&
msym
->
kind
!=
SYM_VMOD
)
{
/*
...
...
@@ -188,13 +197,16 @@ vcc_ParseImport(struct vcc *tl)
again
=
1
;
}
else
{
msym
=
VCC_SymbolGet
(
tl
,
SYM_VMOD
,
SYMTAB_CREATE
,
XREF_NONE
);
msym
=
VCC_SymbolGetTok
(
tl
,
SYM_VMOD
,
SYMTAB_CREATE
,
XREF_NONE
,
mod
);
ERRCHK
(
tl
);
AN
(
msym
);
msym
->
def_b
=
t1
;
msym
->
def_e
=
tl
->
t
;
}
VTAILQ_INSERT_TAIL
(
&
tl
->
sym_vmods
,
msym
,
sideways
);
if
(
tl
->
t
->
tok
==
ID
)
{
if
(
!
vcc_IdIs
(
tl
->
t
,
"from"
))
{
VSB_printf
(
tl
->
sb
,
"Expected 'from path ...'
\n
"
);
...
...
@@ -225,12 +237,17 @@ vcc_ParseImport(struct vcc *tl)
if
(
!
again
)
msym
->
def_e
=
tl
->
t
;
if
(
VFIL_searchpath
(
tl
->
vmod_path
,
vcc_path_dlopen
,
&
hdl
,
fn
,
&
fnpx
))
{
VSB_printf
(
tl
->
sb
,
"Could not load VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnpx
!=
NULL
?
fnpx
:
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
dlerror: %s
\n
"
,
dlerror
());
if
(
VFIL_searchpath
(
tl
->
vmod_path
,
vcc_path_dlopen
,
vop
,
fn
,
&
fnpx
))
{
if
(
vop
->
err
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Could not find VMOD %.*s
\n
"
,
PF
(
mod
));
}
else
{
VSB_printf
(
tl
->
sb
,
"Could not open VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnpx
!=
NULL
?
fnpx
:
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
dlerror: %s
\n
"
,
vop
->
err
);
}
vcc_ErrWhere
(
tl
,
mod
);
free
(
fnpx
);
return
;
...
...
@@ -241,7 +258,7 @@ vcc_ParseImport(struct vcc *tl)
free
(
fnpx
);
bprintf
(
buf
,
"Vmod_%.*s_Data"
,
PF
(
mod
));
vmd
=
dlsym
(
hdl
,
buf
);
vmd
=
dlsym
(
vop
->
hdl
,
buf
);
if
(
vmd
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Malformed VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnp
);
...
...
@@ -250,7 +267,7 @@ vcc_ParseImport(struct vcc *tl)
return
;
}
if
(
vmd
->
vrt_major
==
0
&&
vmd
->
vrt_minor
==
0
&&
strcmp
(
vmd
->
abi
,
VMOD_ABI_Version
)
!=
0
)
{
(
vmd
->
abi
==
NULL
||
strcmp
(
vmd
->
abi
,
VMOD_ABI_Version
)
!=
0
)
)
{
VSB_printf
(
tl
->
sb
,
"Incompatible VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnp
);
VSB_printf
(
tl
->
sb
,
"
\t
ABI mismatch, expected <%s>, got <%s>
\n
"
,
...
...
@@ -282,7 +299,7 @@ vcc_ParseImport(struct vcc *tl)
}
if
(
!
vcc_IdIs
(
mod
,
vmd
->
name
))
{
VSB_printf
(
tl
->
sb
,
"Wrong
VMOD file
%.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"Wrong
file for VMOD
%.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnp
);
VSB_printf
(
tl
->
sb
,
"
\t
Contains vmod
\"
%s
\"\n
"
,
vmd
->
name
);
vcc_ErrWhere
(
tl
,
mod
);
...
...
@@ -298,7 +315,7 @@ vcc_ParseImport(struct vcc *tl)
vcc_ErrWhere2
(
tl
,
msym
->
def_b
,
msym
->
def_e
);
}
if
(
again
)
{
AZ
(
dlclose
(
hdl
));
AZ
(
dlclose
(
vop
->
hdl
));
return
;
}
...
...
lib/libvmod_debug/Makefile.am
View file @
0060ee94
...
...
@@ -5,8 +5,17 @@ libvmod_debug_la_SOURCES = \
vmod_debug_obj.c
\
vmod_debug_dyn.c
include
$(srcdir)/automake_boilerplate.am
# Allow Vmod_wrong*_Data to be exported
libvmod_debug_la_LDFLAGS
=
\
-export-symbols-regex
'Vmod_.*_Data'
\
$(AM_LDFLAGS)
\
$(VMOD_LDFLAGS)
\
@SAN_LDFLAGS@
# not --strict
vmodtoolargs
=
--boilerplate
...
...
lib/libvmod_debug/flint.lnt
View file @
0060ee94
-esym(759, xyzzy_enum_*) // header declaration for symbol '___' defined at (___)
-esym(765, xyzzy_enum_*) // external '___' (___) could be made static
-esym(765, Vmod_wrong*_Data) // external '___' (___) could be made static
-esym(714, Vmod_wrong*_Data) // external '___' (___) could be made static
-esym(754, foo::bar) // local struct member not referenced
lib/libvmod_debug/vmod_debug.c
View file @
0060ee94
...
...
@@ -134,7 +134,7 @@ xyzzy_rot13_bytes(struct req *req, enum vdp_action act, void **priv,
}
}
if
(
i
>=
0
)
retval
=
VDP_bytes
(
req
,
VDP_FLUSH
,
q
,
i
+
1
);
retval
=
VDP_bytes
(
req
,
VDP_FLUSH
,
q
,
i
+
1
L
);
return
(
retval
);
}
...
...
@@ -854,3 +854,44 @@ xyzzy_sndbuf(VRT_CTX, VCL_BYTES arg)
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"SO_SNDBUF fd=%d old=%d new=%d actual=%d"
,
fd
,
oldbuf
,
buflen
,
newbuf
);
}
/**********************************************************************
* For testing import code on bad vmod files (m00003.vtc)
*/
const
struct
vmod_data
Vmod_wrong0_Data
=
{
.
vrt_major
=
0
,
.
vrt_minor
=
0
,
};
//lint -save -e835 A zero has been given as left argument to operatorp'+'
const
struct
vmod_data
Vmod_wrong1_Data
=
{
.
vrt_major
=
VRT_MAJOR_VERSION
,
.
vrt_minor
=
VRT_MINOR_VERSION
+
1
,
};
//lint -restore
static
const
struct
foo
{
int
bar
;
}
foo_struct
[
1
];
const
struct
vmod_data
Vmod_wrong2_Data
=
{
.
vrt_major
=
VRT_MAJOR_VERSION
,
.
vrt_minor
=
VRT_MINOR_VERSION
,
.
name
=
"wrongN"
,
.
func
=
foo_struct
,
.
func_len
=
sizeof
foo_struct
,
.
func_name
=
"foo_struct"
,
.
proto
=
"blablabla"
,
};
const
struct
vmod_data
Vmod_wrong3_Data
=
{
.
vrt_major
=
VRT_MAJOR_VERSION
,
.
vrt_minor
=
VRT_MINOR_VERSION
,
.
name
=
"wrongN"
,
.
func
=
foo_struct
,
.
func_len
=
sizeof
foo_struct
,
.
func_name
=
"foo_struct"
,
.
proto
=
"blablabla"
,
.
abi
=
"abiblabla"
,
};
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