Permalink
Browse files

Don't use HUGE_VAL to signify no upper limit, we run into infinity in

conversions to uintmax_t.  Use zero to disable upper limit check.
Check separately for byte sizes larger than the architecture can do.
  • Loading branch information...
bsdphk committed Feb 13, 2012
1 parent fb3cc4b commit b600f1a1ad5c59ac9e762e1e9530d78b2ef0ea1f
Showing with 10 additions and 4 deletions.
  1. +10 −4 bin/varnishd/mgt/mgt_param.c
@@ -322,7 +322,13 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg,
VCLI_SetResult(cli, CLIS_PARAM);
return;
}
- if ((uintmax_t)((ssize_t)r) != r || r > max) {
+ if ((uintmax_t)((ssize_t)r) != r) {
+ fmt_bytes(cli, (uintmax_t)max);
+ VCLI_Out(cli, " is too large for this architecture.\n");
+ VCLI_SetResult(cli, CLIS_PARAM);
+ return;
+ }
+ if (max != 0. && r > max) {
VCLI_Out(cli, "Must be no more than ");
fmt_bytes(cli, (uintmax_t)max);
VCLI_Out(cli, "\n");
@@ -859,7 +865,7 @@ static const struct parspec input_parspec[] = {
"256m", "bytes" },
#ifdef SENDFILE_WORKS
{ "sendfile_threshold",
- tweak_bytes, &mgt_param.sendfile_threshold, 0, HUGE_VAL,
+ tweak_bytes, &mgt_param.sendfile_threshold, 0, 0,
"The minimum size of objects transmitted with sendfile.",
EXPERIMENTAL,
"1E", "bytes" },
@@ -1183,7 +1189,7 @@ static const struct parspec input_parspec[] = {
"10000", ""},
{ "vsl_space", tweak_bytes,
- &mgt_param.vsl_space, 1024*1024, HUGE_VAL,
+ &mgt_param.vsl_space, 1024*1024, 0,
"The amount of space to allocate for the VSL fifo buffer"
" in the VSM memory segment."
" If you make this too small, varnish{ncsa|log} etc will"
@@ -1193,7 +1199,7 @@ static const struct parspec input_parspec[] = {
"80M", "bytes"},
{ "vsm_space", tweak_bytes,
- &mgt_param.vsm_space, 1024*1024, HUGE_VAL,
+ &mgt_param.vsm_space, 1024*1024, 0,
"The amount of space to allocate for stats counters"
" in the VSM memory segment."
" If you make this too small, some counters will be"

0 comments on commit b600f1a

Please sign in to comment.