From f7bd2799faf6fa398a43be8715d9c0df314b6393 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 25 Oct 1996 18:40:34 +0000 Subject: More economical buffer sizing. svn path=/trunk/; revision=381 --- mxget.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mxget.c b/mxget.c index 7dc2c8fd..c3cfa7b9 100644 --- a/mxget.c +++ b/mxget.c @@ -19,13 +19,17 @@ * This ought to be in the bind library. It's adapted from sendmail. */ +/* minimum possible size of MX record in packet */ +#define MIN_MX_SIZE 8 /* corresp to "a.com 0" w/ terminating space */ + struct mxentry *getmxrecords(name) /* get MX records for given host */ const char *name; { - unsigned char answer[PACKETSZ], MXHostBuf[PACKETSZ], *eom, *cp, *bp; + unsigned char answer[PACKETSZ], *eom, *cp, *bp; int n, ancount, qdcount, buflen, type, pref, ind; - static struct mxentry pmx[(PACKETSZ - HFIXEDSZ) / sizeof(struct mxentry)]; + static struct mxentry pmx[(PACKETSZ - HFIXEDSZ) / MIN_MX_SIZE]; + static char MXHostBuf[PACKETSZ - HFIXEDSZ]; HEADER *hp; n = res_search(name,C_IN,T_MX,(unsigned char*)&answer, sizeof(answer)); -- cgit v1.2.3