mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
fctx_addopt() would leak an rdataset if dns_message_setopt() ever failed;
fixed it by making dns_message_setopt() guarantee to either adopt or free the rdataset
This commit is contained in:
parent
927fe08882
commit
1dd8ee4fd5
3 changed files with 17 additions and 9 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: client.c,v 1.149 2001/02/14 01:46:59 bwelling Exp $ */
|
||||
/* $Id: client.c,v 1.150 2001/02/14 02:51:12 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -823,12 +823,12 @@ ns_client_send(ns_client_t *client) {
|
|||
goto done;
|
||||
if (client->opt != NULL) {
|
||||
result = dns_message_setopt(client->message, client->opt);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto done;
|
||||
/*
|
||||
* XXXRTH dns_message_setopt() should probably do this...
|
||||
*/
|
||||
client->opt = NULL;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
result = dns_message_rendersection(client->message,
|
||||
DNS_SECTION_QUESTION, 0);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: message.h,v 1.91 2001/02/13 01:02:59 bwelling Exp $ */
|
||||
/* $Id: message.h,v 1.92 2001/02/14 02:51:09 gson Exp $ */
|
||||
|
||||
#ifndef DNS_MESSAGE_H
|
||||
#define DNS_MESSAGE_H 1
|
||||
|
|
@ -960,8 +960,11 @@ dns_message_setopt(dns_message_t *msg, dns_rdataset_t *opt);
|
|||
*
|
||||
* Ensures:
|
||||
*
|
||||
* The OPT record will be rendered when dns_message_renderend() is
|
||||
* called.
|
||||
* The OPT record has either been freed or ownership of it has
|
||||
* been transferred to the message.
|
||||
*
|
||||
* If ISC_R_SUCCESS was returned, the OPT record will be rendered
|
||||
* when dns_message_renderend() is called.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: message.c,v 1.176 2001/02/13 01:29:33 bwelling Exp $ */
|
||||
/* $Id: message.c,v 1.177 2001/02/14 02:51:11 gson Exp $ */
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
|
|
@ -2411,18 +2411,23 @@ dns_message_setopt(dns_message_t *msg, dns_rdataset_t *opt) {
|
|||
|
||||
result = dns_rdataset_first(opt);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
goto cleanup;
|
||||
dns_rdataset_current(opt, &rdata);
|
||||
msg->opt_reserved = 11 + rdata.length;
|
||||
result = dns_message_renderreserve(msg, msg->opt_reserved);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
msg->opt_reserved = 0;
|
||||
return (result);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
msg->opt = opt;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
dns_message_puttemprdataset(msg, &opt);
|
||||
return (result);
|
||||
|
||||
}
|
||||
|
||||
dns_rdataset_t *
|
||||
|
|
|
|||
Loading…
Reference in a new issue