From a5214abd0419d49298a4fdc2e2e93c4e30229201 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Fri, 26 Feb 2016 09:20:18 +0100 Subject: [PATCH] udp: udp_send and udp_send_chksum: Check for PCB NULL pointer and PCB must not be the new IP_ANY_TYPE, but a real IPv4 and IPv6 address --- src/core/udp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/udp.c b/src/core/udp.c index fdfb2528..de7a1885 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -492,6 +492,7 @@ chkerr: * - ERR_OK. Successful. No error occurred. * - ERR_MEM. Out of memory. * - ERR_RTE. Could not find route to destination address. + * - ERR_VAL. No PCB or PCB is dual-stack * - More errors could be returned by lower protocol layers. * * @see udp_disconnect() udp_sendto() @@ -499,6 +500,10 @@ chkerr: err_t udp_send(struct udp_pcb *pcb, struct pbuf *p) { + if ((pcb == NULL) || IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) { + return ERR_VAL; + } + /* send to the packet using remote ip and port stored in the pcb */ return udp_sendto(pcb, p, &pcb->remote_ip, pcb->remote_port); } @@ -510,6 +515,10 @@ err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, u8_t have_chksum, u16_t chksum) { + if ((pcb == NULL) || IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) { + return ERR_VAL; + } + /* send to the packet using remote ip and port stored in the pcb */ return udp_sendto_chksum(pcb, p, &pcb->remote_ip, pcb->remote_port, have_chksum, chksum);