mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 21:47:59 +00:00
more checks against the length of the packet
This commit is contained in:
parent
e0d8e8073f
commit
28dff2287e
@ -196,6 +196,9 @@ lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
|
||||
if (LWRES_BUFFER_REMAINING(b) != 0)
|
||||
return (-1);
|
||||
|
||||
gabn = CTXMALLOC(sizeof(lwres_gabnrequest_t));
|
||||
if (gabn == NULL)
|
||||
return (-1);
|
||||
@ -279,7 +282,10 @@ lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* XXXMLG Should check for trailing bytes */
|
||||
if (LWRES_BUFFER_REMAINING(b) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*structp = gabn;
|
||||
return (0);
|
||||
|
@ -134,7 +134,6 @@ lwres_gnbaresponse_render(lwres_context_t *ctx, lwres_gnbaresponse_t *req,
|
||||
}
|
||||
|
||||
/* encode naliases */
|
||||
|
||||
INSIST(SPACE_OK(b, sizeof(isc_uint16_t) * 2));
|
||||
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);
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
goto out;
|
||||
|
||||
if (LWRES_BUFFER_REMAINING(b) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*structp = gnba;
|
||||
return (0);
|
||||
|
||||
out:
|
||||
if (gnba != NULL)
|
||||
lwres_gnbarequest_free(ctx, &gnba);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
@ -238,7 +248,10 @@ lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_lwpacket_t *pkt,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* XXXMLG Should check for trailing bytes */
|
||||
if (LWRES_BUFFER_REMAINING(b) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*structp = gnba;
|
||||
return (0);
|
||||
|
@ -164,6 +164,12 @@ lwres_nooprequest_parse(lwres_context_t *ctx, lwres_buffer_t *b,
|
||||
goto out;
|
||||
}
|
||||
req->data = b->base + b->current;
|
||||
lwres_buffer_forward(b, req->datalength);
|
||||
|
||||
if (LWRES_BUFFER_REMAINING(b) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* success! */
|
||||
*structp = req;
|
||||
@ -206,6 +212,12 @@ lwres_noopresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b,
|
||||
}
|
||||
req->data = b->base + b->current;
|
||||
|
||||
lwres_buffer_forward(b, req->datalength);
|
||||
if (LWRES_BUFFER_REMAINING(b) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* success! */
|
||||
*structp = req;
|
||||
return (0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user