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
0dfa3b8c
Unverified
Commit
0dfa3b8c
authored
Jun 03, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vxp: Use strtod/strtoll consistently for number parsing for vsl (queries)
Fixes #4088
parent
41a1a42d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
20 deletions
+29
-20
r03463.vtc
bin/varnishtest/tests/r03463.vtc
+9
-2
vsl_query.c
lib/libvarnishapi/vsl_query.c
+10
-5
vxp_parse.c
lib/libvarnishapi/vxp_parse.c
+10
-13
No files found.
bin/varnishtest/tests/r03463.vtc
View file @
0dfa3b8c
varnishtest "VSL query lenient int
comparisons
"
varnishtest "VSL query lenient int
#3463 and float precision comparisons #4088
"
varnish v1 -vcl {
varnish v1 -vcl {
import std;
import std;
backend be none;
backend be none;
sub vcl_recv {
sub vcl_recv {
if (req.http.skip != "log") {
if (req.http.skip != "log") {
std.log("float1: 123.456");
std.log("float1: 123.456
7
");
std.log("float2: 123.");
std.log("float2: 123.");
std.log("float3: .456");
std.log("float3: .456");
std.log("float4: 123");
std.log("float4: 123");
...
@@ -37,6 +37,12 @@ logexpect l5 -v v1 -q "VCL_Log:float5 != 42 or ReqHeader:skip eq log" {
...
@@ -37,6 +37,12 @@ logexpect l5 -v v1 -q "VCL_Log:float5 != 42 or ReqHeader:skip eq log" {
fail clear
fail clear
} -start
} -start
#4088
logexpect l6 -v v1 -q "VCL_Log:float1 > 123.456" {
expect 0 1001 Begin rxreq
} -start
client c1 {
client c1 {
txreq
txreq
rxresp
rxresp
...
@@ -50,3 +56,4 @@ logexpect l2 -wait
...
@@ -50,3 +56,4 @@ logexpect l2 -wait
logexpect l3 -wait
logexpect l3 -wait
logexpect l4 -wait
logexpect l4 -wait
logexpect l5 -wait
logexpect l5 -wait
logexpect l6 -wait
lib/libvarnishapi/vsl_query.c
View file @
0dfa3b8c
...
@@ -122,8 +122,9 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
...
@@ -122,8 +122,9 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
const
struct
vex_rhs
*
rhs
;
const
struct
vex_rhs
*
rhs
;
long
long
lhs_int
=
0
;
long
long
lhs_int
=
0
;
double
lhs_float
=
0
.;
double
lhs_float
=
0
.;
const
char
*
b
,
*
e
,
*
q
;
const
char
*
b
,
*
e
;
int
i
,
dq
;
int
i
,
dq
;
char
*
q
=
NULL
;
AN
(
vex
);
AN
(
vex
);
AN
(
rec
);
AN
(
rec
);
...
@@ -205,20 +206,24 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
...
@@ -205,20 +206,24 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
if
(
*
b
==
'\0'
)
if
(
*
b
==
'\0'
)
/* Empty string doesn't match */
/* Empty string doesn't match */
return
(
0
);
return
(
0
);
errno
=
0
;
switch
(
rhs
->
type
)
{
switch
(
rhs
->
type
)
{
case
VEX_INT
:
case
VEX_INT
:
lhs_int
=
(
long
long
)
SF_Parse_Number
(
&
b
,
0
,
&
q
);
lhs_int
=
strtoll
(
b
,
&
q
,
0
);
if
(
errno
)
AN
(
q
);
if
(
q
!=
e
&&
*
q
!=
'.'
)
return
(
0
);
return
(
0
);
break
;
break
;
case
VEX_FLOAT
:
case
VEX_FLOAT
:
lhs_float
=
SF_Parse_Decimal
(
&
b
,
0
,
&
q
);
lhs_float
=
strtod
(
b
,
&
q
);
if
(
errno
)
if
(
q
!=
e
)
return
(
0
);
return
(
0
);
break
;
break
;
default:
default:
WRONG
(
"Wrong RHS type"
);
WRONG
(
"Wrong RHS type"
);
}
}
if
(
errno
!=
0
)
return
(
0
);
break
;
break
;
default:
default:
break
;
break
;
...
...
lib/libvarnishapi/vxp_parse.c
View file @
0dfa3b8c
...
@@ -208,25 +208,22 @@ vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, unsigned vxid)
...
@@ -208,25 +208,22 @@ vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, unsigned vxid)
AN
(
vxp
->
t
->
dec
);
AN
(
vxp
->
t
->
dec
);
ALLOC_OBJ
(
*
prhs
,
VEX_RHS_MAGIC
);
ALLOC_OBJ
(
*
prhs
,
VEX_RHS_MAGIC
);
AN
(
*
prhs
);
AN
(
*
prhs
);
endptr
=
NULL
;
if
(
strchr
(
vxp
->
t
->
dec
,
'.'
))
{
if
(
strchr
(
vxp
->
t
->
dec
,
'.'
))
{
(
*
prhs
)
->
type
=
VEX_FLOAT
;
(
*
prhs
)
->
type
=
VEX_FLOAT
;
(
*
prhs
)
->
val_float
=
VNUM
(
vxp
->
t
->
dec
);
(
*
prhs
)
->
val_float
=
strtod
(
vxp
->
t
->
dec
,
&
endptr
);
if
(
isnan
((
*
prhs
)
->
val_float
))
{
VSB_cat
(
vxp
->
sb
,
"Floating point parse error "
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
}
}
else
{
}
else
{
(
*
prhs
)
->
type
=
VEX_INT
;
(
*
prhs
)
->
type
=
VEX_INT
;
(
*
prhs
)
->
val_int
=
strtoll
(
vxp
->
t
->
dec
,
&
endptr
,
0
);
(
*
prhs
)
->
val_int
=
strtoll
(
vxp
->
t
->
dec
,
&
endptr
,
0
);
}
while
(
isspace
(
*
endptr
))
while
(
isspace
(
*
endptr
))
endptr
++
;
endptr
++
;
if
(
*
endptr
!=
'\0'
)
{
if
(
*
endptr
!=
'\0'
)
{
VSB_cat
(
vxp
->
sb
,
"Integer parse error "
);
VSB_printf
(
vxp
->
sb
,
"%s parse error "
,
(
*
prhs
)
->
type
==
VEX_FLOAT
?
"Floating point"
:
"Integer"
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
return
;
}
}
}
if
(
vxid
&&
(
*
prhs
)
->
type
!=
VEX_INT
)
{
if
(
vxid
&&
(
*
prhs
)
->
type
!=
VEX_INT
)
{
VSB_printf
(
vxp
->
sb
,
"Expected integer got '%.*s' "
,
VSB_printf
(
vxp
->
sb
,
"Expected integer got '%.*s' "
,
PF
(
vxp
->
t
));
PF
(
vxp
->
t
));
...
...
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