2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

more checks against the length of the packet

This commit is contained in:
Michael Graff 2000-01-17 23:43:31 +00:00
parent e0d8e8073f
commit 28dff2287e
3 changed files with 35 additions and 4 deletions

View File

@ -196,6 +196,9 @@ lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
if (ret != 0) if (ret != 0)
return (ret); return (ret);
if (LWRES_BUFFER_REMAINING(b) != 0)
return (-1);
gabn = CTXMALLOC(sizeof(lwres_gabnrequest_t)); gabn = CTXMALLOC(sizeof(lwres_gabnrequest_t));
if (gabn == NULL) if (gabn == NULL)
return (-1); return (-1);
@ -279,7 +282,10 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
goto out; goto out;
} }
/* XXXMLG Should check for trailing bytes */ if (LWRES_BUFFER_REMAINING(b) != 0) {
ret = -1;
goto out;
}
*structp = gabn; *structp = gabn;
return (0); return (0);

View File

@ -134,7 +134,6 @@ lwres_gnbaresponse_render(lwres_context_t *ctx, lwres_gnbaresponse_t *req,
} }
/* encode naliases */ /* encode naliases */
INSIST(SPACE_OK(b, sizeof(isc_uint16_t) * 2)); INSIST(SPACE_OK(b, sizeof(isc_uint16_t) * 2));
lwres_buffer_putuint16(b, req->naliases); lwres_buffer_putuint16(b, req->naliases);
@ -178,10 +177,21 @@ lwres_gnbarequest_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
ret = lwres_addr_parse(b, &gnba->addr); ret = lwres_addr_parse(b, &gnba->addr);
if (ret != 0) if (ret != 0)
return (ret); goto out;
if (LWRES_BUFFER_REMAINING(b) != 0) {
ret = -1;
goto out;
}
*structp = gnba; *structp = gnba;
return (0); return (0);
out:
if (gnba != NULL)
lwres_gnbarequest_free(ctx, &gnba);
return (ret);
} }
int int
@ -238,7 +248,10 @@ lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
goto out; goto out;
} }
/* XXXMLG Should check for trailing bytes */ if (LWRES_BUFFER_REMAINING(b) != 0) {
ret = -1;
goto out;
}
*structp = gnba; *structp = gnba;
return (0); return (0);

View File

@ -164,6 +164,12 @@ lwres_nooprequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
goto out; goto out;
} }
req->data = b->base + b->current; req->data = b->base + b->current;
lwres_buffer_forward(b, req->datalength);
if (LWRES_BUFFER_REMAINING(b) != 0) {
ret = -1;
goto out;
}
/* success! */ /* success! */
*structp = req; *structp = req;
@ -206,6 +212,12 @@ lwres_noopresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
} }
req->data = b->base + b->current; req->data = b->base + b->current;
lwres_buffer_forward(b, req->datalength);
if (LWRES_BUFFER_REMAINING(b) != 0) {
ret = -1;
goto out;
}
/* success! */ /* success! */
*structp = req; *structp = req;
return (0); return (0);