Commit 1b3c07b2 authored by Aurelio Colosimo's avatar Aurelio Colosimo

no_incoming_msg label introduce to skip switch when plen=0

This patch is due to the fact that the code did not correctly handle
the situation of "no incoming message". Since messageType 0 is a SYNC
message type, in those cases an empty message was tried to be handled as a SYNC
message, and led to FAULTY state. This patch seemed to me the least
invasive with respect to the current code.
parent fe65f98c
......@@ -4,6 +4,7 @@
*/
#include <pptp/pptp.h>
#include <pptp/diag.h>
#include "common-fun.h"
int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
......@@ -16,6 +17,9 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (st_com_check_record_update(ppi))
goto state_updated;
if (plen == 0)
goto no_incoming_msg;
switch (ppi->msg_tmp_header.messageType) {
case PPM_ANNOUNCE:
......@@ -31,6 +35,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
}
no_incoming_msg:
if (e == 0)
e = st_com_execute_slave(ppi);
......
......@@ -53,6 +53,9 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
}
if (plen == 0)
goto no_incoming_msg;
switch (ppi->msg_tmp_header.messageType) {
case PPM_ANNOUNCE:
......@@ -167,6 +170,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
}
no_incoming_msg:
failure:
if (e == 0) {
if (DSDEF(ppi)->slaveOnly ||
......
......@@ -20,6 +20,9 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (st_com_check_record_update(ppi))
goto state_updated;
if (plen == 0)
goto no_incoming_msg;
switch (ppi->msg_tmp_header.messageType) {
case PPM_ANNOUNCE:
......@@ -40,6 +43,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
no_incoming_msg:
if (e == 0)
e = st_com_execute_slave(ppi);
......
......@@ -45,6 +45,9 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (st_com_check_record_update(ppi))
goto state_updated;
if (plen == 0)
goto no_incoming_msg;
switch (ppi->msg_tmp_header.messageType) {
case PPM_ANNOUNCE:
......@@ -238,6 +241,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
no_incoming_msg:
if (e == 0)
e = st_com_execute_slave(ppi);
......
......@@ -10,6 +10,9 @@ int pp_uncalibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
int e = 0; /* error var, to check errors in msg handling */
if (plen == 0)
goto no_incoming_msg;
switch (ppi->msg_tmp_header.messageType) {
case PPM_ANNOUNCE:
......@@ -29,6 +32,7 @@ int pp_uncalibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
}
no_incoming_msg:
if (e == 0)
e = st_com_execute_slave(ppi);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment