mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
fixed bug #45818: API functions should check if type of ip_addr_t parameter matches the pcb type
This commit is contained in:
parent
06d8dba4a0
commit
43b18b20cc
@ -450,6 +450,10 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
|
|||||||
int max_pcb_list = NUM_TCP_PCB_LISTS;
|
int max_pcb_list = NUM_TCP_PCB_LISTS;
|
||||||
struct tcp_pcb *cpcb;
|
struct tcp_pcb *cpcb;
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL);
|
LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL);
|
||||||
|
|
||||||
#if SO_REUSE
|
#if SO_REUSE
|
||||||
@ -756,6 +760,10 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
|
|||||||
ip_addr_t local_ip_tmp;
|
ip_addr_t local_ip_tmp;
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
||||||
|
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port));
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port));
|
||||||
|
@ -557,6 +557,10 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
|
|||||||
ip_addr_t dst_ip_tmp;
|
ip_addr_t dst_ip_tmp;
|
||||||
#endif /* LWIP_IPV6 && LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */
|
#endif /* LWIP_IPV6 && LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n"));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n"));
|
||||||
|
|
||||||
#if LWIP_IPV6 || (LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS)
|
#if LWIP_IPV6 || (LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS)
|
||||||
@ -639,6 +643,10 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_i
|
|||||||
ip_addr_t src_ip_tmp;
|
ip_addr_t src_ip_tmp;
|
||||||
#endif /* LWIP_IPV6 && LWIP_IPV4 */
|
#endif /* LWIP_IPV6 && LWIP_IPV4 */
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* PCB local address is IP_ANY_ADDR? */
|
/* PCB local address is IP_ANY_ADDR? */
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
if (PCB_ISIPV6(pcb)) {
|
if (PCB_ISIPV6(pcb)) {
|
||||||
@ -705,6 +713,11 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d
|
|||||||
u8_t ip_proto;
|
u8_t ip_proto;
|
||||||
u8_t ttl;
|
u8_t ttl;
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, src_ip) ||
|
||||||
|
!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
#if LWIP_IPV4 && IP_SOF_BROADCAST
|
#if LWIP_IPV4 && IP_SOF_BROADCAST
|
||||||
/* broadcast filter? */
|
/* broadcast filter? */
|
||||||
if (!ip_get_option(pcb, SOF_BROADCAST) &&
|
if (!ip_get_option(pcb, SOF_BROADCAST) &&
|
||||||
@ -901,6 +914,10 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
|
|||||||
struct udp_pcb *ipcb;
|
struct udp_pcb *ipcb;
|
||||||
u8_t rebind;
|
u8_t rebind;
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_bind(ipaddr = "));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_bind(ipaddr = "));
|
||||||
ip_addr_debug_print(UDP_DEBUG | LWIP_DBG_TRACE, ipaddr);
|
ip_addr_debug_print(UDP_DEBUG | LWIP_DBG_TRACE, ipaddr);
|
||||||
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, (", port = %"U16_F")\n", port));
|
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, (", port = %"U16_F")\n", port));
|
||||||
@ -986,6 +1003,10 @@ udp_connect(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
|
|||||||
{
|
{
|
||||||
struct udp_pcb *ipcb;
|
struct udp_pcb *ipcb;
|
||||||
|
|
||||||
|
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pcb->local_port == 0) {
|
if (pcb->local_port == 0) {
|
||||||
err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
|
err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user