2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

It's probably a bad idea to pre-allocate 64K buffers for each lookup as soon

as you read in the batch file.  Don't.
This commit is contained in:
Michael Sawyer
2000-07-13 01:22:38 +00:00
parent 9317787889
commit 738310d8cf
5 changed files with 24 additions and 13 deletions

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: dig.c,v 1.61 2000/07/12 17:44:03 mws Exp $ */ /* $Id: dig.c,v 1.62 2000/07/13 01:22:33 mws Exp $ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
@@ -1047,7 +1047,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
strcpy(lookup->rttext, "ptr"); strcpy(lookup->rttext, "ptr");
strcpy(lookup->rctext, "in"); strcpy(lookup->rctext, "in");
lookup->namespace[0] = 0; lookup->namespace[0] = 0;
lookup->sendspace[0] = 0; lookup->sendspace = NULL;
lookup->sendmsg = NULL; lookup->sendmsg = NULL;
lookup->name = NULL; lookup->name = NULL;
lookup->oname = NULL; lookup->oname = NULL;
@@ -1112,7 +1112,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
lookup->rttext[0] = 0; lookup->rttext[0] = 0;
lookup->rctext[0] = 0; lookup->rctext[0] = 0;
lookup->namespace[0] = 0; lookup->namespace[0] = 0;
lookup->sendspace[0] = 0; lookup->sendspace = NULL;
lookup->sendmsg = NULL; lookup->sendmsg = NULL;
lookup->name = NULL; lookup->name = NULL;
lookup->oname = NULL; lookup->oname = NULL;
@@ -1189,7 +1189,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
lookup->pending = ISC_FALSE; lookup->pending = ISC_FALSE;
lookup->rctext[0] = 0; lookup->rctext[0] = 0;
lookup->namespace[0] = 0; lookup->namespace[0] = 0;
lookup->sendspace[0] = 0; lookup->sendspace = NULL;
lookup->sendmsg = NULL; lookup->sendmsg = NULL;
lookup->name = NULL; lookup->name = NULL;
lookup->oname = NULL; lookup->oname = NULL;

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: dighost.c,v 1.78 2000/07/13 00:32:20 mws Exp $ */ /* $Id: dighost.c,v 1.79 2000/07/13 01:22:34 mws Exp $ */
/* /*
* Notice to programmers: Do not use this code as an example of how to * Notice to programmers: Do not use this code as an example of how to
@@ -252,7 +252,7 @@ requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
strncpy(looknew->rttext, lookold-> rttext, 32); strncpy(looknew->rttext, lookold-> rttext, 32);
strncpy(looknew->rctext, lookold-> rctext, 32); strncpy(looknew->rctext, lookold-> rctext, 32);
looknew->namespace[0] = 0; looknew->namespace[0] = 0;
looknew->sendspace[0] = 0; looknew->sendspace = NULL;
looknew->sendmsg = NULL; looknew->sendmsg = NULL;
looknew->name = NULL; looknew->name = NULL;
looknew->oname = NULL; looknew->oname = NULL;
@@ -645,6 +645,8 @@ clear_query(dig_query_t *query) {
if (ISC_LINK_LINKED(&query->lengthbuf, link)) if (ISC_LINK_LINKED(&query->lengthbuf, link))
ISC_LIST_DEQUEUE(query->lengthlist, &query->lengthbuf, ISC_LIST_DEQUEUE(query->lengthlist, &query->lengthbuf,
link); link);
INSIST(query->recvspace != NULL);
isc_mem_put(mctx, query->recvspace, COMMSIZE);
isc_buffer_invalidate(&query->recvbuf); isc_buffer_invalidate(&query->recvbuf);
isc_buffer_invalidate(&query->lengthbuf); isc_buffer_invalidate(&query->lengthbuf);
isc_mem_free(mctx, query); isc_mem_free(mctx, query);
@@ -683,6 +685,8 @@ try_clear_lookup(dig_lookup_t *lookup) {
} }
if (lookup->timer != NULL) if (lookup->timer != NULL)
isc_timer_detach(&lookup->timer); isc_timer_detach(&lookup->timer);
INSIST(lookup->sendspace != NULL);
isc_mem_put(mctx, lookup->sendspace, COMMSIZE);
ptr = lookup; ptr = lookup;
lookup = ISC_LIST_NEXT(lookup, link); lookup = ISC_LIST_NEXT(lookup, link);
@@ -1129,6 +1133,10 @@ setup_lookup(dig_lookup_t *lookup) {
lookup->querysig = NULL; lookup->querysig = NULL;
} }
lookup->sendspace = isc_mem_get(mctx, COMMSIZE);
if (lookup->sendspace == NULL)
fatal("memory allocation failure");
debug("starting to render the message"); debug("starting to render the message");
isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE); isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE);
result = dns_message_renderbegin(lookup->sendmsg, &lookup->sendbuf); result = dns_message_renderbegin(lookup->sendmsg, &lookup->sendbuf);
@@ -1172,6 +1180,9 @@ setup_lookup(dig_lookup_t *lookup) {
ISC_LIST_INIT(query->recvlist); ISC_LIST_INIT(query->recvlist);
ISC_LIST_INIT(query->lengthlist); ISC_LIST_INIT(query->lengthlist);
query->sock = NULL; query->sock = NULL;
query->recvspace = isc_mem_get(mctx, COMMSIZE);
if (query->recvspace == NULL)
fatal("memory allocation failure");
isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE); isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
isc_buffer_init(&query->lengthbuf, query->lengthspace, 2); isc_buffer_init(&query->lengthbuf, query->lengthspace, 2);

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: host.c,v 1.37 2000/07/10 18:02:29 bwelling Exp $ */ /* $Id: host.c,v 1.38 2000/07/13 01:22:35 mws Exp $ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
@@ -661,7 +661,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
strncpy(lookup->rttext, querytype, 32); strncpy(lookup->rttext, querytype, 32);
strncpy(lookup->rctext, queryclass, 32); strncpy(lookup->rctext, queryclass, 32);
lookup->namespace[0] = 0; lookup->namespace[0] = 0;
lookup->sendspace[0] = 0; lookup->sendspace = NULL;
lookup->sendmsg = NULL; lookup->sendmsg = NULL;
lookup->name = NULL; lookup->name = NULL;
lookup->oname = NULL; lookup->oname = NULL;

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: dig.h,v 1.30 2000/07/10 18:02:31 bwelling Exp $ */ /* $Id: dig.h,v 1.31 2000/07/13 01:22:38 mws Exp $ */
#ifndef DIG_H #ifndef DIG_H
#define DIG_H #define DIG_H
@@ -99,7 +99,7 @@ struct dig_lookup {
isc_buffer_t namebuf; isc_buffer_t namebuf;
isc_buffer_t onamebuf; isc_buffer_t onamebuf;
isc_buffer_t sendbuf; isc_buffer_t sendbuf;
char sendspace[COMMSIZE]; char *sendspace;
dns_name_t *name; dns_name_t *name;
isc_timer_t *timer; isc_timer_t *timer;
isc_interval_t interval; isc_interval_t interval;
@@ -139,7 +139,7 @@ struct dig_query {
isc_buffer_t recvbuf, isc_buffer_t recvbuf,
lengthbuf, lengthbuf,
slbuf; slbuf;
char recvspace[COMMSIZE], char *recvspace,
lengthspace[4], lengthspace[4],
slspace[4]; slspace[4];
isc_socket_t *sock; isc_socket_t *sock;

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: nslookup.c,v 1.23 2000/07/05 23:28:30 mws Exp $ */ /* $Id: nslookup.c,v 1.24 2000/07/13 01:22:36 mws Exp $ */
#include <config.h> #include <config.h>
@@ -651,7 +651,7 @@ addlookup(char *opt) {
strncpy (lookup->rttext, deftype, MXNAME); strncpy (lookup->rttext, deftype, MXNAME);
strncpy (lookup->rctext, defclass, MXNAME); strncpy (lookup->rctext, defclass, MXNAME);
lookup->namespace[0]=0; lookup->namespace[0]=0;
lookup->sendspace[0]=0; lookup->sendspace = NULL;
lookup->sendmsg=NULL; lookup->sendmsg=NULL;
lookup->name=NULL; lookup->name=NULL;
lookup->oname=NULL; lookup->oname=NULL;