Commit 72e11083 authored by Daniel Salzman's avatar Daniel Salzman

Check for packet reservation everywhere

parent ee7dd0f9
......@@ -192,7 +192,7 @@ int axfr_process_query(knot_pkt_t *pkt, knotd_qdata_t *qdata)
/* Reserve space for TSIG. */
int ret = knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
if (ret != KNOT_EOK) {
return ret;
return KNOT_STATE_FAIL;
}
/* Answer current packet (or continue). */
......
......@@ -668,7 +668,10 @@ int internet_process_query(knot_pkt_t *pkt, knotd_qdata_t *qdata)
NS_NEED_AUTH(qdata, qdata->extra->zone->name, ACL_ACTION_NONE);
/* Reserve space for TSIG. */
knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
int ret = knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
if (ret != KNOT_EOK) {
return KNOT_STATE_FAIL;
}
}
NS_NEED_ZONE_CONTENTS(qdata, KNOT_RCODE_SERVFAIL); /* Expired */
......
......@@ -262,7 +262,10 @@ static int ixfr_answer_soa(knot_pkt_t *pkt, knotd_qdata_t *qdata)
}
/* Reserve space for TSIG. */
knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
int ret = knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
if (ret != KNOT_EOK) {
return KNOT_STATE_FAIL;
}
/* Guaranteed to have zone contents. */
const zone_node_t *apex = qdata->extra->zone->contents->apex;
......@@ -270,7 +273,7 @@ static int ixfr_answer_soa(knot_pkt_t *pkt, knotd_qdata_t *qdata)
if (knot_rrset_empty(&soa_rr)) {
return KNOT_STATE_FAIL;
}
int ret = knot_pkt_put(pkt, 0, &soa_rr, 0);
ret = knot_pkt_put(pkt, 0, &soa_rr, 0);
if (ret != KNOT_EOK) {
qdata->rcode = KNOT_RCODE_SERVFAIL;
return KNOT_STATE_FAIL;
......@@ -322,10 +325,13 @@ int ixfr_process_query(knot_pkt_t *pkt, knotd_qdata_t *qdata)
}
/* Reserve space for TSIG. */
knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
int ret = knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
if (ret != KNOT_EOK) {
return KNOT_STATE_FAIL;
}
/* Answer current packet (or continue). */
int ret = xfr_process_list(pkt, &ixfr_process_changeset, qdata);
ret = xfr_process_list(pkt, &ixfr_process_changeset, qdata);
switch (ret) {
case KNOT_ESPACE: /* Couldn't write more, send packet and continue. */
return KNOT_STATE_PRODUCE; /* Check for more. */
......
......@@ -59,7 +59,10 @@ int notify_process_query(knot_pkt_t *pkt, knotd_qdata_t *qdata)
}
/* Reserve space for TSIG. */
knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
int ret = knot_pkt_reserve(pkt, knot_tsig_wire_size(&qdata->sign.tsig_key));
if (ret != KNOT_EOK) {
return KNOT_STATE_FAIL;
}
/* SOA RR in answer may be included, recover serial. */
zone_t *zone = (zone_t *)qdata->extra->zone;
......
......@@ -64,7 +64,10 @@ int sign_packet(knot_pkt_t *pkt, sign_context_t *sign_ctx)
size_t *wire_size = &pkt->size;
size_t max_size = pkt->max_size;
knot_pkt_reserve(pkt, knot_tsig_wire_size(sign_ctx->tsig_key));
int ret = knot_pkt_reserve(pkt, knot_tsig_wire_size(sign_ctx->tsig_key));
if (ret != KNOT_EOK) {
return ret;
}
return knot_tsig_sign(wire, wire_size, max_size, NULL, 0,
sign_ctx->digest, &sign_ctx->digest_size,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment