mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 07:35:26 +00:00
fix allocation of buffer for rdata
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tsig.c,v 1.8 1999/09/02 15:56:32 bwelling Exp $
|
* $Id: tsig.c,v 1.9 1999/09/10 02:42:12 explorer Exp $
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -185,6 +185,8 @@ dns_tsig_sign(dns_message_t *msg) {
|
|||||||
if (is_response(msg))
|
if (is_response(msg))
|
||||||
REQUIRE(msg->querytsig != NULL);
|
REQUIRE(msg->querytsig != NULL);
|
||||||
|
|
||||||
|
dynbuf = NULL;
|
||||||
|
|
||||||
mctx = msg->mctx;
|
mctx = msg->mctx;
|
||||||
key = msg->tsigkey;
|
key = msg->tsigkey;
|
||||||
|
|
||||||
@@ -348,34 +350,21 @@ dns_tsig_sign(dns_message_t *msg) {
|
|||||||
tsig->signature = NULL;
|
tsig->signature = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There should be a better way of accessing msg->scratchpad */
|
|
||||||
rdata = NULL;
|
rdata = NULL;
|
||||||
ret = dns_message_gettemprdata(msg, &rdata);
|
ret = dns_message_gettemprdata(msg, &rdata);
|
||||||
if (ret != ISC_R_SUCCESS)
|
if (ret != ISC_R_SUCCESS)
|
||||||
goto cleanup_signature;
|
goto cleanup_signature;
|
||||||
tries = 0;
|
tries = 0;
|
||||||
dynbuf = ISC_LIST_TAIL(msg->scratchpad);
|
ret = isc_buffer_allocate(msg->mctx, &dynbuf, 512,
|
||||||
INSIST(dynbuf != NULL);
|
ISC_BUFFERTYPE_BINARY);
|
||||||
rdatabuf = *dynbuf;
|
ret = dns_rdata_fromstruct(rdata, dns_rdataclass_any,
|
||||||
while (tries < 2) {
|
dns_rdatatype_tsig, tsig, dynbuf);
|
||||||
ret = dns_rdata_fromstruct(rdata, dns_rdataclass_any,
|
if (ret != ISC_R_SUCCESS) {
|
||||||
dns_rdatatype_tsig, tsig, &rdatabuf);
|
isc_buffer_free(&dynbuf);
|
||||||
if (ret == ISC_R_SUCCESS)
|
goto cleanup_signature;
|
||||||
break;
|
|
||||||
else if (ret == ISC_R_NOSPACE) {
|
|
||||||
if (++tries == 2)
|
|
||||||
return (ISC_R_NOMEMORY);
|
|
||||||
ret = isc_buffer_allocate(msg->mctx, &dynbuf, 512,
|
|
||||||
ISC_BUFFERTYPE_BINARY);
|
|
||||||
if (ret != ISC_R_SUCCESS)
|
|
||||||
goto cleanup_signature;
|
|
||||||
ISC_LIST_APPEND(msg->scratchpad, dynbuf, link);
|
|
||||||
rdatabuf = *dynbuf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto cleanup_signature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dns_message_takebuffer(msg, &dynbuf);
|
||||||
msg->tsig = tsig;
|
msg->tsig = tsig;
|
||||||
|
|
||||||
owner = NULL;
|
owner = NULL;
|
||||||
|
Reference in New Issue
Block a user