-
Notifications
You must be signed in to change notification settings - Fork 1
/
bind-9.9.9-P1-xfer-limit-0.0.1.patch
166 lines (162 loc) · 5.69 KB
/
bind-9.9.9-P1-xfer-limit-0.0.1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
diff --git a/bin/named/config.c b/bin/named/config.c
index 4798272..8254260 100644
--- a/bin/named/config.c
+++ b/bin/named/config.c
@@ -196,6 +196,7 @@ options {\n\
alt-transfer-source-v6 *;\n\
max-transfer-time-in 120;\n\
max-transfer-time-out 120;\n\
+ max-transfer-size-in 0;\n\
max-transfer-idle-in 60;\n\
max-transfer-idle-out 60;\n\
max-retry-time 1209600; /* 2 weeks */\n\
diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c
index 5b473d1..b33eb00 100644
--- a/bin/named/zoneconf.c
+++ b/bin/named/zoneconf.c
@@ -1553,6 +1553,11 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
dns_zone_setidlein(mayberaw, cfg_obj_asuint32(obj) * 60);
obj = NULL;
+ result = ns_config_get(maps, "max-transfer-size-in", &obj);
+ INSIST(result == ISC_R_SUCCESS && obj != NULL);
+ dns_zone_setmaxxfrinsize(mayberaw, cfg_obj_asuint32(obj));
+
+ obj = NULL;
result = ns_config_get(maps, "max-refresh-time", &obj);
INSIST(result == ISC_R_SUCCESS && obj != NULL);
dns_zone_setmaxrefreshtime(mayberaw, cfg_obj_asuint32(obj));
diff --git a/doc/misc/options b/doc/misc/options
index f23568c..cd42d7f 100644
--- a/doc/misc/options
+++ b/doc/misc/options
@@ -175,6 +175,7 @@ options {
max-transfer-idle-out <integer>;
max-transfer-time-in <integer>;
max-transfer-time-out <integer>;
+ max-transfer-size-in <integer>;
max-udp-size <integer>;
memstatistics <boolean>;
memstatistics-file <quoted_string>;
@@ -403,6 +404,7 @@ view <string> [ <class> ] {
max-transfer-idle-out <integer>;
max-transfer-time-in <integer>;
max-transfer-time-out <integer>;
+ max-transfer-size-in <integer>;
max-udp-size <integer>;
min-refresh-time <integer>;
min-retry-time <integer>;
diff --git a/lib/bind9/check.c b/lib/bind9/check.c
index cbfa830..85281c4 100644
--- a/lib/bind9/check.c
+++ b/lib/bind9/check.c
@@ -1339,6 +1339,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
{ "max-transfer-idle-out", MASTERZONE | SLAVEZONE },
{ "max-transfer-time-in", SLAVEZONE | STUBZONE | STREDIRECTZONE },
{ "max-transfer-time-out", MASTERZONE | SLAVEZONE },
+ { "max-transfer-size-in", SLAVEZONE | STUBZONE | STREDIRECTZONE },
{ "min-refresh-time", SLAVEZONE | STUBZONE | STREDIRECTZONE },
{ "min-retry-time", SLAVEZONE | STUBZONE | STREDIRECTZONE },
{ "notify", MASTERZONE | SLAVEZONE },
diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h
index 987d06f..57de4b8 100644
--- a/lib/dns/include/dns/zone.h
+++ b/lib/dns/include/dns/zone.h
@@ -1113,6 +1113,27 @@ dns_zone_getmaxxfrin(dns_zone_t *zone);
*/
void
+dns_zone_setmaxxfrinsize(dns_zone_t *zone, isc_uint32_t maxxfrinsize);
+/*%<
+ * Set the maximum data size (bytes) that a zone transfer in (AXFR/IXFR)
+ * of this zone will use before being aborted.
+ *
+ * Requires:
+ * \li 'zone' to be valid initialised zone.
+ */
+
+isc_uint32_t
+dns_zone_getmaxxfrinsize(dns_zone_t *zone);
+/*%<
+ * Returns the maximum transfer data size (bytes) for this zone. This will be
+ * either the value set by the last call to dns_zone_setmaxxfrinsize() or
+ * the default value of 0 bytes(unlimited).
+ *
+ * Requires:
+ *\li 'zone' to be valid initialised zone.
+ */
+
+void
dns_zone_setmaxxfrout(dns_zone_t *zone, isc_uint32_t maxxfrout);
/*%<
* Set the maximum time (in seconds) that a zone transfer out (AXFR/IXFR)
diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c
index aec238d..9ef61e4 100644
--- a/lib/dns/xfrin.c
+++ b/lib/dns/xfrin.c
@@ -1346,6 +1346,15 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) {
* Update the number of bytes received.
*/
xfr->nbytes += tcpmsg->buffer.used;
+ if ( dns_zone_getmaxxfrinsize(xfr->zone) != 0 &&
+ xfr->nbytes > dns_zone_getmaxxfrinsize(xfr->zone) ) {
+ result = DNS_R_BADZONE;
+ xfrin_log(xfr, ISC_LOG_ERROR,
+ "transfered size is exceeded; transferd: %d, limit: %d.",
+ xfr->nbytes,
+ dns_zone_getmaxxfrinsize(xfr->zone) );
+ goto failure;
+ }
/*
* Take the context back.
diff --git a/lib/dns/zone.c b/lib/dns/zone.c
index 490248a..0bbcb95 100644
--- a/lib/dns/zone.c
+++ b/lib/dns/zone.c
@@ -288,6 +288,7 @@ struct dns_zone {
dns_io_t *writeio;
isc_uint32_t maxxfrin;
isc_uint32_t maxxfrout;
+ isc_uint32_t maxxfrinsize;
isc_uint32_t idlein;
isc_uint32_t idleout;
isc_event_t ctlevent;
@@ -955,6 +956,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
zone->tsigkey = NULL;
zone->maxxfrin = MAX_XFER_TIME;
zone->maxxfrout = MAX_XFER_TIME;
+ zone->maxxfrinsize = 0;
zone->ssutable = NULL;
zone->sigvalidityinterval = 30 * 24 * 3600;
zone->sigresigninginterval = 7 * 24 * 3600;
@@ -12681,6 +12683,21 @@ dns_zone_getmaxxfrin(dns_zone_t *zone) {
}
void
+dns_zone_setmaxxfrinsize(dns_zone_t *zone, isc_uint32_t maxxfrinsize) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ zone->maxxfrinsize = maxxfrinsize;
+}
+
+isc_uint32_t
+dns_zone_getmaxxfrinsize(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ return (zone->maxxfrinsize);
+}
+
+
+void
dns_zone_setmaxxfrout(dns_zone_t *zone, isc_uint32_t maxxfrout) {
REQUIRE(DNS_ZONE_VALID(zone));
zone->maxxfrout = maxxfrout;
diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c
index d95a03a..39c208d 100644
--- a/lib/isccfg/namedconf.c
+++ b/lib/isccfg/namedconf.c
@@ -1603,6 +1603,7 @@ zone_clauses[] = {
{ "max-transfer-idle-out", &cfg_type_uint32, 0 },
{ "max-transfer-time-in", &cfg_type_uint32, 0 },
{ "max-transfer-time-out", &cfg_type_uint32, 0 },
+ { "max-transfer-size-in", &cfg_type_uint32, 0 },
{ "min-refresh-time", &cfg_type_uint32, 0 },
{ "min-retry-time", &cfg_type_uint32, 0 },
{ "multi-master", &cfg_type_boolean, 0 },