Skip to content

Commit 91174e4

Browse files
committed
lib/dnssec: allow validating some RRsets around 64 KiB size
Only with libknot >= 3.4 though (which is not released yet).
1 parent 3c2052f commit 91174e4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

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)