mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-13 20:40:00 -04:00
fixed handling of size+unit when value would be too large for internal
representation. max-cache-size config option now takes a size-spec like 'datasize', except 'default' is not allowed.
This commit is contained in:
parent
3fe45d9897
commit
bedfa169b4
5 changed files with 64 additions and 24 deletions
6
CHANGES
6
CHANGES
|
|
@ -1,3 +1,9 @@
|
|||
250. [bug] fixed handling of size+unit when value would be too
|
||||
large for internal representation.
|
||||
|
||||
249. [cleanup] max-cache-size config option now takes a size-spec
|
||||
like 'datasize', except 'default' is not allowed.
|
||||
|
||||
248. [bug] global lame-ttl option was not being printed when
|
||||
config structures were written out.
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ options {
|
|||
coresize 100;
|
||||
datasize 101;
|
||||
files 230;
|
||||
max-cache-size 200000;
|
||||
max-cache-size 1m;
|
||||
stacksize 231;
|
||||
cleaning-interval 1000;
|
||||
heartbeat-interval 1001;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: confctx.c,v 1.67 2000/06/09 15:54:26 brister Exp $ */
|
||||
/* $Id: confctx.c,v 1.68 2000/06/09 22:13:20 brister Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -946,7 +946,7 @@ dns_c_ctx_optionsprint(FILE *fp, int indent, dns_c_options_t *options)
|
|||
PRINT_INTEGER(min_roots, "min-roots");
|
||||
PRINT_INTEGER(serial_queries, "serial-queries");
|
||||
PRINT_INTEGER(sig_valid_interval, "sig-validity-interval");
|
||||
PRINT_INTEGER(max_cache_size, "max-cache-size");
|
||||
PRINT_AS_SIZE_CLAUSE(max_cache_size, "max-cache-size");
|
||||
|
||||
PRINT_AS_SIZE_CLAUSE(data_size, "datasize");
|
||||
PRINT_AS_SIZE_CLAUSE(stack_size, "stacksize");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: confparser.y,v 1.95 2000/06/09 15:03:24 brister Exp $ */
|
||||
/* $Id: confparser.y,v 1.96 2000/06/09 22:13:21 brister Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ static void parser_warning(isc_boolean_t lasttoken,
|
|||
static void parser_complain(isc_boolean_t is_warning,
|
||||
isc_boolean_t last_token,
|
||||
const char *format, va_list args);
|
||||
static isc_boolean_t unit_to_uint32(char *in, isc_uint32_t *out);
|
||||
static isc_result_t unit_to_uint32(char *in, isc_uint32_t *out);
|
||||
static const char * token_to_keyword(int token);
|
||||
static void yyerror(const char *);
|
||||
static dns_peerlist_t *currentpeerlist(dns_c_ctx_t *cfg,
|
||||
|
|
@ -1919,8 +1919,15 @@ size_clause: L_DATASIZE size_spec
|
|||
YYABORT;
|
||||
}
|
||||
}
|
||||
| L_MAX_CACHE_SIZE L_INTEGER
|
||||
| L_MAX_CACHE_SIZE size_spec
|
||||
{
|
||||
if ($2 == DNS_C_SIZE_SPEC_DEFAULT) {
|
||||
parser_error(ISC_FALSE,
|
||||
"cannot specific 'default' for "
|
||||
"'max-cache-size'");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
tmpres = dns_c_ctx_setmaxcachesize(currcfg, $2);
|
||||
if (tmpres == ISC_R_EXISTS) {
|
||||
parser_error(ISC_FALSE,
|
||||
|
|
@ -1939,22 +1946,26 @@ size_spec: any_string
|
|||
{
|
||||
isc_uint32_t result;
|
||||
|
||||
if (unit_to_uint32($1, &result)) {
|
||||
tmpres = unit_to_uint32($1, &result);
|
||||
if (tmpres == ISC_R_SUCCESS) {
|
||||
$$ = result;
|
||||
if ($$ == DNS_C_SIZE_SPEC_DEFAULT) {
|
||||
isc_uint32_t newi = DNS_C_SIZE_SPEC_DEFAULT-1;
|
||||
parser_warning(ISC_FALSE,
|
||||
"value (%lu) too big, "
|
||||
"reducing to %lu",
|
||||
(unsigned long)$$,
|
||||
(unsigned long)newi);
|
||||
$$ = newi; }
|
||||
} else {
|
||||
} else if (tmpres == ISC_R_RANGE) {
|
||||
$$ = DNS_C_SIZE_SPEC_UNLIM;
|
||||
parser_warning(ISC_FALSE,
|
||||
"invalid value %s: using 'unlimited'",
|
||||
$1);
|
||||
} else if (tmpres == ISC_R_FAILURE) {
|
||||
parser_warning(ISC_FALSE,
|
||||
"invalid unit string '%s', Using "
|
||||
"default", $1);
|
||||
"'default'", $1);
|
||||
$$ = DNS_C_SIZE_SPEC_DEFAULT;
|
||||
} else {
|
||||
parser_warning(ISC_FALSE,
|
||||
"unknown result: %s: using 'default'",
|
||||
isc_result_totext(tmpres));
|
||||
$$ = DNS_C_SIZE_SPEC_DEFAULT;
|
||||
}
|
||||
|
||||
isc_mem_free(memctx, $1);
|
||||
}
|
||||
| L_INTEGER
|
||||
|
|
@ -3784,12 +3795,19 @@ view_option: L_FORWARD zone_forward_opt
|
|||
YYABORT;
|
||||
}
|
||||
}
|
||||
| L_MAX_CACHE_SIZE L_INTEGER
|
||||
| L_MAX_CACHE_SIZE size_spec
|
||||
{
|
||||
dns_c_view_t *view = dns_c_ctx_getcurrview(currcfg);
|
||||
|
||||
INSIST(view != NULL);
|
||||
|
||||
if ($2 == DNS_C_SIZE_SPEC_DEFAULT) {
|
||||
parser_error(ISC_FALSE,
|
||||
"cannot specific 'default' for "
|
||||
"'max-cache-size'");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
tmpres = dns_c_view_setmaxcachesize(view, $2);
|
||||
if (tmpres == ISC_R_EXISTS) {
|
||||
parser_error(ISC_FALSE,
|
||||
|
|
@ -5761,44 +5779,60 @@ intuit_token(const char *string)
|
|||
* Conversion Routines
|
||||
*/
|
||||
|
||||
static isc_boolean_t
|
||||
static isc_result_t
|
||||
unit_to_uint32(char *in, isc_uint32_t *out) {
|
||||
char *start = in;
|
||||
int c, units_done = 0;
|
||||
isc_uint32_t result = 0L;
|
||||
isc_uint32_t maxK = 4194304; /* 2^32 / 1024 */
|
||||
isc_uint32_t maxM = 4096; /* 2^32 / (1024 * 1024) */
|
||||
isc_uint32_t maxG = 4; /* 2^32 / (1024 * 1024 * 1024) */
|
||||
|
||||
INSIST(in != NULL);
|
||||
|
||||
for (; (c = *in) != '\0'; in++) {
|
||||
if (units_done)
|
||||
return (ISC_FALSE);
|
||||
return (ISC_R_FAILURE);
|
||||
if (isdigit((unsigned char)c)) {
|
||||
result *= 10;
|
||||
result += (c - '0');
|
||||
} else {
|
||||
if (start == in) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
switch (c) {
|
||||
case 'k':
|
||||
case 'K':
|
||||
if (result > maxK) {
|
||||
return (ISC_R_RANGE);
|
||||
}
|
||||
result *= 1024;
|
||||
units_done = 1;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
if (result > maxM) {
|
||||
return (ISC_R_RANGE);
|
||||
}
|
||||
result *= (1024*1024);
|
||||
units_done = 1;
|
||||
break;
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (result > maxG) {
|
||||
return (ISC_R_RANGE);
|
||||
}
|
||||
result *= (1024*1024*1024);
|
||||
units_done = 1;
|
||||
break;
|
||||
default:
|
||||
return (ISC_FALSE);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*out = result;
|
||||
return (ISC_TRUE);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: confview.c,v 1.35 2000/06/09 15:03:25 brister Exp $ */
|
||||
/* $Id: confview.c,v 1.36 2000/06/09 22:13:23 brister Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -678,7 +678,7 @@ dns_c_view_print(FILE *fp, int indent, dns_c_view_t *view) {
|
|||
PRINT_INT32(max_cache_ttl, "max-cache-ttl");
|
||||
PRINT_INT32(sig_valid_interval, "sig-validity-interval");
|
||||
|
||||
PRINT_INT32(max_cache_size, "max-cache-size");
|
||||
PRINT_AS_SIZE_CLAUSE(max_cache_size, "max-cache-size");
|
||||
|
||||
if (view->additional_data != NULL) {
|
||||
dns_c_printtabs(fp, indent + 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue