Skip to content

Commit 5778588

Browse files
committed
lib/dnssec: allow validating some RRsets around 64 KiB size
- only with libknot >= 3.4 though (which is not released yet) - use stack instead of static buffer (saves RAM; see code comment)
1 parent 3c2052f commit 5778588

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Improvements
55
------------
66
- tweak the default run_dir on non-Linux (!1481)
77

8+
Bugfixes
9+
--------
10+
- fix validation of RRsets around 64 KiB size; needs libknot >= 3.4 (!1497)
11+
812

913
Knot Resolver 6.0.5 (2024-01-09)
1014
================================

lib/dnssec/signature.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,27 @@ static int sign_ctx_add_records(dnssec_sign_ctx_t *ctx, const knot_rrset_t *cove
179179
if (!ctx || !covered || trim_labels < 0)
180180
return kr_error(EINVAL);
181181

182-
// huge block of rrsets can be optionally created
183-
static uint8_t wire_buffer[KNOT_WIRE_MAX_PKTSIZE];
182+
/* Buffer allocation notes:
183+
- We should be able to afford a larger stack allocation,
184+
as we don't use (this function in) threads.
185+
- The format that's signed has decompressed names,
186+
so it can be significantly more than 64 KiB,
187+
even if it originally did fit into a 64 KiB packet.
188+
Let's tolerate a double of that.
189+
- Older libknot only allowed passing 16-bit size limit.
190+
*/
191+
uint8_t wire_buffer[
192+
#if KNOT_VERSION_HEX < 0x030400
193+
KNOT_WIRE_MAX_PKTSIZE
194+
#else
195+
knot_rrset_size_estimate(covered)
196+
#endif
197+
];
184198
int written = knot_rrset_to_wire(covered, wire_buffer, sizeof(wire_buffer), NULL);
185-
if (written < 0)
199+
if (written < 0) {
200+
kr_assert(KNOT_VERSION_HEX < 0x030400 || written != KNOT_ESPACE);
186201
return written;
202+
}
187203

188204
/* Set original ttl. */
189205
int ret = adjust_wire_ttl(wire_buffer, written, orig_ttl);

0 commit comments

Comments
 (0)