summaryrefslogtreecommitdiff
path: root/accel-pppd/ppp/ppp_ipcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/ppp/ppp_ipcp.c')
-rw-r--r--accel-pppd/ppp/ppp_ipcp.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c
index aee0317d..63818e8c 100644
--- a/accel-pppd/ppp/ppp_ipcp.c
+++ b/accel-pppd/ppp/ppp_ipcp.c
@@ -392,13 +392,14 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp, uint8_t *data, int size)
while (size > 0) {
hdr = (struct ipcp_opt_hdr_t *)data;
+ if (!hdr->len || hdr->len > size)
+ break;
+
ropt = _malloc(sizeof(*ropt));
memset(ropt, 0, sizeof(*ropt));
- if (hdr->len > size)
- ropt->len = size;
- else
- ropt->len = hdr->len;
+ ropt->len = hdr->len;
+
ropt->hdr = hdr;
ropt->state = IPCP_OPT_NONE;
list_add_tail(&ropt->entry, &ipcp->ropt_list);
@@ -503,7 +504,10 @@ static int ipcp_recv_conf_rej(struct ppp_ipcp_t *ipcp, uint8_t *data, int size)
while (size > 0) {
hdr = (struct ipcp_opt_hdr_t *)data;
-
+
+ if (!hdr->len || hdr->len > size)
+ break;
+
list_for_each_entry(lopt, &ipcp->options, entry) {
if (lopt->id == hdr->id) {
if (!lopt->h->recv_conf_rej)
@@ -542,6 +546,9 @@ static int ipcp_recv_conf_nak(struct ppp_ipcp_t *ipcp, uint8_t *data, int size)
while (size > 0) {
hdr = (struct ipcp_opt_hdr_t *)data;
+ if (!hdr->len || hdr->len > size)
+ break;
+
list_for_each_entry(lopt, &ipcp->options, entry) {
if (lopt->id == hdr->id) {
if (conf_ppp_verbose) {
@@ -582,6 +589,9 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp, uint8_t *data, int size)
while (size > 0) {
hdr = (struct ipcp_opt_hdr_t *)data;
+ if (!hdr->len || hdr->len > size)
+ break;
+
list_for_each_entry(lopt, &ipcp->options, entry) {
if (lopt->id == hdr->id) {
if (conf_ppp_verbose) {