From f1092e671a5f1f78ad53abf33c6d13d11f22ef29 Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Wed, 26 Jan 2000 22:22:41 +0000 Subject: [PATCH] set the used region before parsing. Gotta love buffers, they'll keep ya honest --- lib/lwres/lwres_gabn.c | 10 +++++++--- lib/lwres/lwresutil.c | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/lwres/lwres_gabn.c b/lib/lwres/lwres_gabn.c index 59be346584..192e6c464a 100644 --- a/lib/lwres/lwres_gabn.c +++ b/lib/lwres/lwres_gabn.c @@ -83,7 +83,8 @@ lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req, * just checked for it. */ lwres_buffer_putuint16(b, datalen); - lwres_buffer_putmem(b, req->name, datalen + 1); /* trailing NUL */ + lwres_buffer_putmem(b, req->name, datalen); + lwres_buffer_putuint8(b, 0); /* trailing NUL */ INSIST(LWRES_BUFFER_AVAILABLECOUNT(b) == 0); @@ -149,14 +150,16 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req, datalen = req->realnamelen; INSIST(SPACE_OK(b, (unsigned int)(datalen + 2 + 1))); lwres_buffer_putuint16(b, datalen); - lwres_buffer_putmem(b, req->realname, datalen + 1); + lwres_buffer_putmem(b, req->realname, datalen); + lwres_buffer_putuint8(b, 0); /* encode the aliases */ for (x = 0 ; x < req->naliases ; x++) { datalen = req->aliaslen[x]; INSIST(SPACE_OK(b, (unsigned int)(datalen + 2 + 1))); lwres_buffer_putuint16(b, datalen); - lwres_buffer_putmem(b, req->aliases[x], datalen + 1); + lwres_buffer_putmem(b, req->aliases[x], datalen); + lwres_buffer_putuint8(b, 0); } /* encode the addresses */ @@ -171,6 +174,7 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req, } INSIST(LWRES_BUFFER_AVAILABLECOUNT(b) == 0); + INSIST(b->used == pkt->length); return (LWRES_R_SUCCESS); } diff --git a/lib/lwres/lwresutil.c b/lib/lwres/lwresutil.c index 878b9fe5c6..afe7980eb6 100644 --- a/lib/lwres/lwresutil.c +++ b/lib/lwres/lwresutil.c @@ -145,6 +145,7 @@ lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, goto out; lwres_buffer_init(&b_in, buffer, recvlen); + b_in.used = recvlen; /* * Parse the packet header. @@ -252,6 +253,7 @@ lwres_getnamebyaddr(lwres_context_t *ctx, isc_uint32_t addrtype, goto out; lwres_buffer_init(&b_in, buffer, recvlen); + b_in.used = recvlen; /* * Parse the packet header.