Skip to content

Commit 5fb892a

Browse files
committed
- Fix that fast_reload does not terminate the server
on config read failure after malloc failure. Thanks to Qifan Zhang, Palo Alto Networks, for the report.
1 parent 55e9532 commit 5fb892a

2 files changed

Lines changed: 43 additions & 40 deletions

File tree

doc/Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
so the internal messaging stays correct. Also it does
5656
not exit the server if stats pipe communication fails.
5757
Thanks to Qifan Zhang, Palo Alto Networks, for the report.
58+
- Fix that fast_reload does not terminate the server
59+
on config read failure after malloc failure. Thanks to
60+
Qifan Zhang, Palo Alto Networks, for the report.
5861

5962
16 June 2026: Wouter
6063
- Fix to disallow $INCLUDE for secondary zones. Start up

util/configparser.y

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ server_send_client_subnet: VAR_SEND_CLIENT_SUBNET STRING_ARG
664664
#ifdef CLIENT_SUBNET
665665
OUTYY(("P(server_send_client_subnet:%s)\n", $2));
666666
if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet, $2))
667-
fatal_exit("out of memory adding client-subnet");
667+
yyerror("out of memory");
668668
#else
669669
OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
670670
free($2);
@@ -677,7 +677,7 @@ server_client_subnet_zone: VAR_CLIENT_SUBNET_ZONE STRING_ARG
677677
OUTYY(("P(server_client_subnet_zone:%s)\n", $2));
678678
if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet_zone,
679679
$2))
680-
fatal_exit("out of memory adding client-subnet-zone");
680+
yyerror("out of memory");
681681
#else
682682
OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
683683
free($2);
@@ -2036,7 +2036,7 @@ server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG
20362036
OUTYY(("P(server_access_control:%s %s)\n", $2, $3));
20372037
validate_acl_action($3);
20382038
if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3))
2039-
fatal_exit("out of memory adding acl");
2039+
yyerror("out of memory");
20402040
}
20412041
;
20422042
server_interface_action: VAR_INTERFACE_ACTION STRING_ARG STRING_ARG
@@ -2045,7 +2045,7 @@ server_interface_action: VAR_INTERFACE_ACTION STRING_ARG STRING_ARG
20452045
validate_acl_action($3);
20462046
if(!cfg_str2list_insert(
20472047
&cfg_parser->cfg->interface_actions, $2, $3))
2048-
fatal_exit("out of memory adding acl");
2048+
yyerror("out of memory");
20492049
}
20502050
;
20512051
server_module_conf: VAR_MODULE_CONF STRING_ARG
@@ -2416,37 +2416,40 @@ server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
24162416
} else if(strcmp($3, "nodefault")==0) {
24172417
if(!cfg_strlist_insert(&cfg_parser->cfg->
24182418
local_zones_nodefault, $2))
2419-
fatal_exit("out of memory adding local-zone");
2419+
yyerror("out of memory");
24202420
free($3);
24212421
#ifdef USE_IPSET
24222422
} else if(strcmp($3, "ipset")==0) {
24232423
size_t len = strlen($2);
24242424
/* Make sure to add the trailing dot.
24252425
* These are str compared to domain names. */
24262426
if($2[len-1] != '.') {
2427+
char* prev = $2;
24272428
if(!($2 = realloc($2, len+2))) {
2428-
fatal_exit("out of memory adding local-zone");
2429+
yyerror("out of memory");
2430+
free(prev);
2431+
} else {
2432+
$2[len] = '.';
2433+
$2[len+1] = 0;
24292434
}
2430-
$2[len] = '.';
2431-
$2[len+1] = 0;
24322435
}
24332436
if(!cfg_strlist_insert(&cfg_parser->cfg->
24342437
local_zones_ipset, $2))
2435-
fatal_exit("out of memory adding local-zone");
2438+
yyerror("out of memory");
24362439
free($3);
24372440
#endif
24382441
} else {
24392442
if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones,
24402443
$2, $3))
2441-
fatal_exit("out of memory adding local-zone");
2444+
yyerror("out of memory");
24422445
}
24432446
}
24442447
;
24452448
server_local_data: VAR_LOCAL_DATA STRING_ARG
24462449
{
24472450
OUTYY(("P(server_local_data:%s)\n", $2));
24482451
if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2))
2449-
fatal_exit("out of memory adding local-data");
2452+
yyerror("out of memory");
24502453
}
24512454
;
24522455
server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
@@ -2458,7 +2461,7 @@ server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
24582461
if(ptr) {
24592462
if(!cfg_strlist_insert(&cfg_parser->cfg->
24602463
local_data, ptr))
2461-
fatal_exit("out of memory adding local-data");
2464+
yyerror("out of memory");
24622465
} else {
24632466
yyerror("local-data-ptr could not be reversed");
24642467
}
@@ -2522,8 +2525,7 @@ server_wait_limit_netblock: VAR_WAIT_LIMIT_NETBLOCK STRING_ARG STRING_ARG
25222525
} else {
25232526
if(!cfg_str2list_insert(&cfg_parser->cfg->
25242527
wait_limit_netblock, $2, $3))
2525-
fatal_exit("out of memory adding "
2526-
"wait-limit-netblock");
2528+
yyerror("out of memory");
25272529
}
25282530
}
25292531
;
@@ -2537,8 +2539,7 @@ server_wait_limit_cookie_netblock: VAR_WAIT_LIMIT_COOKIE_NETBLOCK STRING_ARG STR
25372539
} else {
25382540
if(!cfg_str2list_insert(&cfg_parser->cfg->
25392541
wait_limit_cookie_netblock, $2, $3))
2540-
fatal_exit("out of memory adding "
2541-
"wait-limit-cookie-netblock");
2542+
yyerror("out of memory");
25422543
}
25432544
}
25442545
;
@@ -2570,7 +2571,7 @@ server_dns64_ignore_aaaa: VAR_DNS64_IGNORE_AAAA STRING_ARG
25702571
OUTYY(("P(dns64_ignore_aaaa:%s)\n", $2));
25712572
if(!cfg_strlist_insert(&cfg_parser->cfg->dns64_ignore_aaaa,
25722573
$2))
2573-
fatal_exit("out of memory adding dns64-ignore-aaaa");
2574+
yyerror("out of memory");
25742575
}
25752576
;
25762577
server_nat64_prefix: VAR_NAT64_PREFIX STRING_ARG
@@ -2835,8 +2836,7 @@ server_ratelimit_for_domain: VAR_RATELIMIT_FOR_DOMAIN STRING_ARG STRING_ARG
28352836
} else {
28362837
if(!cfg_str2list_insert(&cfg_parser->cfg->
28372838
ratelimit_for_domain, $2, $3))
2838-
fatal_exit("out of memory adding "
2839-
"ratelimit-for-domain");
2839+
yyerror("out of memory");
28402840
}
28412841
}
28422842
;
@@ -2850,8 +2850,7 @@ server_ratelimit_below_domain: VAR_RATELIMIT_BELOW_DOMAIN STRING_ARG STRING_ARG
28502850
} else {
28512851
if(!cfg_str2list_insert(&cfg_parser->cfg->
28522852
ratelimit_below_domain, $2, $3))
2853-
fatal_exit("out of memory adding "
2854-
"ratelimit-below-domain");
2853+
yyerror("out of memory");
28552854
}
28562855
}
28572856
;
@@ -3085,8 +3084,7 @@ server_edns_client_string: VAR_EDNS_CLIENT_STRING STRING_ARG STRING_ARG
30853084
OUTYY(("P(server_edns_client_string:%s %s)\n", $2, $3));
30863085
if(!cfg_str2list_insert(
30873086
&cfg_parser->cfg->edns_client_strings, $2, $3))
3088-
fatal_exit("out of memory adding "
3089-
"edns-client-string");
3087+
yyerror("out of memory");
30903088
}
30913089
;
30923090
server_edns_client_string_opcode: VAR_EDNS_CLIENT_STRING_OPCODE STRING_ARG
@@ -3404,30 +3402,33 @@ view_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
34043402
} else if(strcmp($3, "nodefault")==0) {
34053403
if(!cfg_strlist_insert(&cfg_parser->cfg->views->
34063404
local_zones_nodefault, $2))
3407-
fatal_exit("out of memory adding local-zone");
3405+
yyerror("out of memory");
34083406
free($3);
34093407
#ifdef USE_IPSET
34103408
} else if(strcmp($3, "ipset")==0) {
34113409
size_t len = strlen($2);
34123410
/* Make sure to add the trailing dot.
34133411
* These are str compared to domain names. */
34143412
if($2[len-1] != '.') {
3413+
char* prev = $2;
34153414
if(!($2 = realloc($2, len+2))) {
3416-
fatal_exit("out of memory adding local-zone");
3415+
yyerror("out of memory");
3416+
free(prev);
3417+
} else {
3418+
$2[len] = '.';
3419+
$2[len+1] = 0;
34173420
}
3418-
$2[len] = '.';
3419-
$2[len+1] = 0;
34203421
}
34213422
if(!cfg_strlist_insert(&cfg_parser->cfg->views->
34223423
local_zones_ipset, $2))
3423-
fatal_exit("out of memory adding local-zone");
3424+
yyerror("out of memory");
34243425
free($3);
34253426
#endif
34263427
} else {
34273428
if(!cfg_str2list_insert(
34283429
&cfg_parser->cfg->views->local_zones,
34293430
$2, $3))
3430-
fatal_exit("out of memory adding local-zone");
3431+
yyerror("out of memory");
34313432
}
34323433
}
34333434
;
@@ -3437,23 +3438,22 @@ view_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG
34373438
validate_respip_action($3);
34383439
if(!cfg_str2list_insert(
34393440
&cfg_parser->cfg->views->respip_actions, $2, $3))
3440-
fatal_exit("out of memory adding per-view "
3441-
"response-ip action");
3441+
yyerror("out of memory");
34423442
}
34433443
;
34443444
view_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG
34453445
{
34463446
OUTYY(("P(view_response_ip_data:%s)\n", $2));
34473447
if(!cfg_str2list_insert(
34483448
&cfg_parser->cfg->views->respip_data, $2, $3))
3449-
fatal_exit("out of memory adding response-ip-data");
3449+
yyerror("out of memory");
34503450
}
34513451
;
34523452
view_local_data: VAR_LOCAL_DATA STRING_ARG
34533453
{
34543454
OUTYY(("P(view_local_data:%s)\n", $2));
34553455
if(!cfg_strlist_insert(&cfg_parser->cfg->views->local_data, $2)) {
3456-
fatal_exit("out of memory adding local-data");
3456+
yyerror("out of memory");
34573457
}
34583458
}
34593459
;
@@ -3466,7 +3466,7 @@ view_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
34663466
if(ptr) {
34673467
if(!cfg_strlist_insert(&cfg_parser->cfg->views->
34683468
local_data, ptr))
3469-
fatal_exit("out of memory adding local-data");
3469+
yyerror("out of memory");
34703470
} else {
34713471
yyerror("local-data-ptr could not be reversed");
34723472
}
@@ -3806,15 +3806,15 @@ server_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG
38063806
validate_respip_action($3);
38073807
if(!cfg_str2list_insert(&cfg_parser->cfg->respip_actions,
38083808
$2, $3))
3809-
fatal_exit("out of memory adding response-ip");
3809+
yyerror("out of memory");
38103810
}
38113811
;
38123812
server_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG
38133813
{
38143814
OUTYY(("P(server_response_ip_data:%s)\n", $2));
38153815
if(!cfg_str2list_insert(&cfg_parser->cfg->respip_data,
38163816
$2, $3))
3817-
fatal_exit("out of memory adding response-ip-data");
3817+
yyerror("out of memory");
38183818
}
38193819
;
38203820
dnscstart: VAR_DNSCRYPT
@@ -3866,15 +3866,15 @@ dnsc_dnscrypt_provider_cert: VAR_DNSCRYPT_PROVIDER_CERT STRING_ARG
38663866
log_warn("dnscrypt-provider-cert %s is a duplicate", $2);
38673867
free($2);
38683868
} else if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert, $2)) {
3869-
fatal_exit("out of memory adding dnscrypt-provider-cert");
3869+
yyerror("out of memory");
38703870
}
38713871
}
38723872
;
38733873
dnsc_dnscrypt_provider_cert_rotated: VAR_DNSCRYPT_PROVIDER_CERT_ROTATED STRING_ARG
38743874
{
38753875
OUTYY(("P(dnsc_dnscrypt_provider_cert_rotated:%s)\n", $2));
38763876
if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert_rotated, $2))
3877-
fatal_exit("out of memory adding dnscrypt-provider-cert-rotated");
3877+
yyerror("out of memory");
38783878
}
38793879
;
38803880
dnsc_dnscrypt_secret_key: VAR_DNSCRYPT_SECRET_KEY STRING_ARG
@@ -3884,7 +3884,7 @@ dnsc_dnscrypt_secret_key: VAR_DNSCRYPT_SECRET_KEY STRING_ARG
38843884
log_warn("dnscrypt-secret-key: %s is a duplicate", $2);
38853885
free($2);
38863886
} else if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_secret_key, $2)) {
3887-
fatal_exit("out of memory adding dnscrypt-secret-key");
3887+
yyerror("out of memory");
38883888
}
38893889
}
38903890
;
@@ -4230,7 +4230,7 @@ server_tcp_connection_limit: VAR_TCP_CONNECTION_LIMIT STRING_ARG STRING_ARG
42304230
yyerror("positive number expected");
42314231
else {
42324232
if(!cfg_str2list_insert(&cfg_parser->cfg->tcp_connection_limits, $2, $3))
4233-
fatal_exit("out of memory adding tcp connection limit");
4233+
yyerror("out of memory");
42344234
}
42354235
}
42364236
;

0 commit comments

Comments
 (0)