netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/1 netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code
Dan Carpenter says: "Smatch complains that the value for "cmd" comes from the network and can't be trusted."
Add pptp_msg_name() helper function that checks for the array boundary.
Fixes f09943fefe6b ("[NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port")
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/linux/netfilter/nf_conntrack_pptp.h | 2 +- net/ipv4/netfilter/nf_nat_pptp.c | 7 +-- net/netfilter/nf_conntrack_pptp.c | 62 ++++++++++++--------- 3 files changed, 38 insertions(+), 33 deletions(-)
include/linux/netfilter/nf_conntrack_pptp.h +1 -1
@@ -10,7 +10,7 @@#include <net/netfilter/nf_conntrack_expect.h> #include <uapi/linux/netfilter/nf_conntrack_tuple_common.h> -extern const char *const pptp_msg_name[]; +extern const char *const pptp_msg_name (u_int16_t msg);/* state of the control session */ enum pptp_ctrlsess_state {
net/ipv4/netfilter/nf_nat_pptp.c +2 -5
@@ -166,8 +166,7 @@ pptp_outbound_pkt(struct sk_buff *skb,break ;default :pr_debug ("unknown outbound packet 0x%04x:%s\n" , msg, - msg <=PPTP_MSG_MAX ? pptp_msg_name[msg] : - pptp_msg_name[0 ]); +pptp_msg_name (msg)); fallthrough;case PPTP_SET_LINK_INFO :/* only need to NAT in case PAC is behind NAT box */
@@ -268,9 +267,7 @@ pptp_inbound_pkt(struct sk_buff *skb, pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID);break ;default : -pr_debug ("unknown inbound packet %s\n" , - msg <=PPTP_MSG_MAX ? pptp_msg_name[msg] : - pptp_msg_name[0 ]); +pr_debug ("unknown inbound packet %s\n" ,pptp_msg_name (msg)); fallthrough;case PPTP_START_SESSION_REQUEST :case PPTP_START_SESSION_REPLY :
net/netfilter/nf_conntrack_pptp.c +35 -27
129 lines not on this page · raw message
Signature · 1 line
2.20.1