2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

1354. [bug] nsupdate was extremely wasteful of memory.

This commit is contained in:
Mark Andrews 2002-08-06 03:21:59 +00:00
parent fd0b3725dd
commit a6211a2f23
2 changed files with 28 additions and 29 deletions

View File

@ -1,3 +1,5 @@
1354. [bug] nsupdate was extremely wasteful of memory.
1355. [tuning] Reduce the number of events / quantum for zone tasks. 1355. [tuning] Reduce the number of events / quantum for zone tasks.
1354. [bug] Fix DNSSEC wildcard proof for CNAME/DNAME. 1354. [bug] Fix DNSSEC wildcard proof for CNAME/DNAME.

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: nsupdate.c,v 1.119 2002/06/17 02:30:40 marka Exp $ */ /* $Id: nsupdate.c,v 1.120 2002/08/06 03:21:59 marka Exp $ */
#include <config.h> #include <config.h>
@ -84,8 +84,7 @@ extern int h_errno;
#endif #endif
#define MAXCMD (4 * 1024) #define MAXCMD (4 * 1024)
#define INITDATA (32 * 1024) #define MAXWIRE (64 * 1024)
#define MAXDATA (64 * 1024)
#define PACKETSIZE ((64 * 1024) - 1) #define PACKETSIZE ((64 * 1024) - 1)
#define INITTEXT (2 * 1024) #define INITTEXT (2 * 1024)
#define MAXTEXT (128 * 1024) #define MAXTEXT (128 * 1024)
@ -697,12 +696,12 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
dns_rdata_t *rdata) dns_rdata_t *rdata)
{ {
char *cmdline = *cmdlinep; char *cmdline = *cmdlinep;
isc_buffer_t source, *buf = NULL; isc_buffer_t source, *buf = NULL, *newbuf = NULL;
isc_region_t r;
isc_lex_t *lex = NULL; isc_lex_t *lex = NULL;
dns_rdatacallbacks_t callbacks; dns_rdatacallbacks_t callbacks;
isc_result_t result; isc_result_t result;
dns_name_t *rn; dns_name_t *rn;
int bufsz = INITDATA;
while (*cmdline != 0 && isspace((unsigned char)*cmdline)) while (*cmdline != 0 && isspace((unsigned char)*cmdline))
cmdline++; cmdline++;
@ -713,33 +712,31 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
rn = userzone; rn = userzone;
else else
rn = origin; rn = origin;
do { result = isc_lex_create(mctx, strlen(cmdline), &lex);
result = isc_lex_create(mctx, strlen(cmdline), &lex); check_result(result, "isc_lex_create");
check_result(result, "isc_lex_create"); isc_buffer_init(&source, cmdline, strlen(cmdline));
isc_buffer_init(&source, cmdline, strlen(cmdline)); isc_buffer_add(&source, strlen(cmdline));
isc_buffer_add(&source, strlen(cmdline)); result = isc_lex_openbuffer(lex, &source);
result = isc_lex_openbuffer(lex, &source); check_result(result, "isc_lex_openbuffer");
check_result(result, "isc_lex_openbuffer"); result = isc_buffer_allocate(mctx, &buf, MAXWIRE);
if (buf != NULL) check_result(result, "isc_buffer_allocate");
isc_buffer_free(&buf); result = dns_rdata_fromtext(rdata, rdataclass, rdatatype, lex,
if (bufsz > MAXDATA) { rn, ISC_FALSE, mctx, buf,
fprintf(stderr, "could not allocate enough " &callbacks);
"space for the rdata\n"); isc_lex_destroy(&lex);
exit(1); if (result == ISC_R_SUCCESS) {
} isc_buffer_usedregion(buf, &r);
result = isc_buffer_allocate(mctx, &buf, bufsz); result = isc_buffer_allocate(mctx, &newbuf, r.length);
check_result(result, "isc_buffer_allocate"); check_result(result, "isc_buffer_allocate");
result = dns_rdata_fromtext(rdata, rdataclass, isc_buffer_putmem(newbuf, r.base, r.length);
rdatatype, isc_buffer_usedregion(newbuf, &r);
lex, rn, ISC_FALSE, mctx, dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
buf, &callbacks); isc_buffer_free(&buf);
bufsz *= 2; dns_message_takebuffer(msg, &newbuf);
isc_lex_destroy(&lex); } else {
} while (result == ISC_R_NOSPACE);
dns_message_takebuffer(msg, &buf);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "invalid rdata format: %s\n", fprintf(stderr, "invalid rdata format: %s\n",
isc_result_totext(result)); isc_result_totext(result));
isc_buffer_free(&buf);
return (STATUS_SYNTAX); return (STATUS_SYNTAX);
} }
} else { } else {