mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
set the used region before parsing. Gotta love buffers, they'll keep ya honest
This commit is contained in:
parent
77d886b04e
commit
f1092e671a
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user