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
0f7f757c
Commit
0f7f757c
authored
Feb 27, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sensible limits for VCL_INT and VCL_BYTES
parent
898b2fe5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
vrt.h
include/vrt.h
+15
-0
vmod_std_conversions.c
lib/libvmod_std/vmod_std_conversions.c
+3
-3
No files found.
include/vrt.h
View file @
0f7f757c
...
...
@@ -211,6 +211,21 @@ typedef vtim_real VCL_TIME;
typedef
struct
vcl
*
VCL_VCL
;
typedef
void
VCL_VOID
;
/*
* technically, as our VCL_INT is int64_t, its limits are INT64_MIN/INT64_MAX.
*
* Yet, for conversions, we use VNUMpfx with a double intermediate, so above
* 2^53 we see rounding errors. In order to catch a potential floor rounding
* error, we make our limit 2^53-1
*
* Ref: https://stackoverflow.com/a/1848762
*/
#define VCL_INT_MAX ((INT64_C(1)<<53)-1)
#define VCL_INT_MIN (-VCL_INT_MAX)
#define VCL_BYTES_MAX VCL_INT_MAX
#define VCL_BYTES_MIN 0
struct
vrt_type
{
unsigned
magic
;
#define VRT_TYPE_MAGIC 0xa943bc32
...
...
lib/libvmod_std/vmod_std_conversions.c
View file @
0f7f757c
...
...
@@ -81,7 +81,7 @@ vmod_integer(VRT_CTX, VCL_STRING p, VCL_INT i)
return
(
i
);
r
=
trunc
(
r
);
if
(
r
>
INT64_MAX
||
r
<
INT64
_MIN
)
if
(
r
>
VCL_INT_MAX
||
r
<
VCL_INT
_MIN
)
return
(
i
);
return
((
VCL_INT
)
r
);
...
...
@@ -158,7 +158,7 @@ vmod_real2integer(VRT_CTX, VCL_REAL r, VCL_INT i)
if
(
!
isfinite
(
r
))
return
(
i
);
r
=
round
(
r
);
if
(
r
>
INT64_MAX
||
r
<
INT64
_MIN
)
if
(
r
>
VCL_INT_MAX
||
r
<
VCL_INT
_MIN
)
return
(
i
);
return
((
VCL_INT
)
r
);
}
...
...
@@ -182,7 +182,7 @@ vmod_time2integer(VRT_CTX, VCL_TIME t, VCL_INT i)
if
(
!
isfinite
(
t
))
return
(
i
);
t
=
round
(
t
);
if
(
t
>
INT64_MAX
||
t
<
INT64
_MIN
)
if
(
t
>
VCL_INT_MAX
||
t
<
VCL_INT
_MIN
)
return
(
i
);
return
((
VCL_INT
)
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