mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 12:35:26 +00:00
Possible null-pointer dereference
In unit test if_fail check for nullptr is always located after dereferencing this null pointer. This patch introduces correct order: first check, then use
This commit is contained in:
parent
7eba14cb76
commit
f7d215043c
@ -45,8 +45,8 @@ START_TEST(readname_basic)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == sizeof(data));
|
||||
@ -64,8 +64,8 @@ START_TEST(readname_anydata)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == sizeof(data));
|
||||
@ -83,8 +83,8 @@ START_TEST(readname_short_buf)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -108,8 +108,8 @@ START_TEST(readname_long_label)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -164,8 +164,8 @@ START_TEST(readname_overflow)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -189,8 +189,8 @@ START_TEST(readname_jump_earlier)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 20, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == sizeof(data));
|
||||
@ -218,8 +218,8 @@ START_TEST(readname_jump_earlier_jump)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0x18, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == sizeof(data));
|
||||
@ -252,8 +252,8 @@ START_TEST(readname_jump_maxdepth)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0x30, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == sizeof(data));
|
||||
@ -278,8 +278,8 @@ START_TEST(readname_jump_later)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == 13);
|
||||
@ -300,8 +300,8 @@ START_TEST(readname_half_jump)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -319,8 +319,8 @@ START_TEST(readname_jump_toolong)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 0, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -339,8 +339,8 @@ START_TEST(readname_jump_loop_label)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 10, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -359,8 +359,8 @@ START_TEST(readname_jump_loop_jump)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
offset = mdns_readname(p, 10, &domain);
|
||||
pbuf_free(p);
|
||||
fail_unless(offset == MDNS_READNAME_ERROR);
|
||||
@ -603,8 +603,8 @@ START_TEST(compress_full_match)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
@ -638,8 +638,8 @@ START_TEST(compress_full_match_subset)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
@ -675,8 +675,8 @@ START_TEST(compress_full_match_jump)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
@ -710,8 +710,8 @@ START_TEST(compress_no_match)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
@ -744,8 +744,8 @@ START_TEST(compress_2nd_label)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "lwip", 4);
|
||||
@ -779,8 +779,8 @@ START_TEST(compress_2nd_label_short)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
@ -816,8 +816,8 @@ START_TEST(compress_jump_to_jump)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
@ -856,8 +856,8 @@ START_TEST(compress_long_match)
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_ROM);
|
||||
p->payload = (void *)(size_t)data;
|
||||
fail_if(p == NULL);
|
||||
p->payload = (void *)(size_t)data;
|
||||
|
||||
memset(&domain, 0, sizeof(domain));
|
||||
res = mdns_domain_add_label(&domain, "foobar", 6);
|
||||
|
Loading…
x
Reference in New Issue
Block a user