Add missing null checks.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
Matthias Hofmann 2018-06-14 13:41:27 +02:00 committed by Simon Goldschmidt
parent e61b925709
commit 6ac21515ca
2 changed files with 14 additions and 1 deletions

View File

@ -500,6 +500,9 @@ void
netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
{
ip_addr_t old_addr;
LWIP_ERROR("netif_set_ipaddr: invalid netif", netif != NULL, return);
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
if (ipaddr == NULL) {
ipaddr = IP4_ADDR_ANY4;
@ -564,6 +567,8 @@ netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
#endif
LWIP_ASSERT_CORE_LOCKED();
LWIP_ERROR("netif_set_netmask: invalid netif", netif != NULL, return);
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
if (netmask == NULL) {
netmask = IP4_ADDR_ANY4;
@ -623,6 +628,8 @@ netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
#endif
LWIP_ASSERT_CORE_LOCKED();
LWIP_ERROR("netif_set_gw: invalid netif", netif != NULL, return);
/* Don't propagate NULL pointer (IPv4 ANY) to subsequent functions */
if (gw == NULL) {
gw = IP4_ADDR_ANY4;

View File

@ -1218,6 +1218,8 @@ tcp_build_sack_option(const struct tcp_pcb *pcb, u32_t *opts, u8_t num_sacks)
static void
tcp_build_wnd_scale_option(u32_t *opts)
{
LWIP_ASSERT("tcp_build_wnd_scale_option: invalid opts", opts != NULL);
/* Pad with one NOP option to make everything nicely aligned */
opts[0] = PP_HTONL(0x01030300 | TCP_RCV_SCALE);
}
@ -1818,7 +1820,11 @@ tcp_output_alloc_header_common(u32_t ackno, u16_t optlen, u16_t datalen,
u16_t src_port, u16_t dst_port, u8_t flags, u16_t wnd)
{
struct tcp_hdr *tcphdr;
struct pbuf *p = pbuf_alloc(PBUF_IP, TCP_HLEN + optlen + datalen, PBUF_RAM);
struct pbuf *p;
LWIP_ASSERT("tcp_output_alloc_header: invalid pcb", pcb != NULL);
p = pbuf_alloc(PBUF_IP, TCP_HLEN + optlen + datalen, PBUF_RAM);
if (p != NULL) {
LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr",
(p->len >= TCP_HLEN + optlen));