Added check: PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or else the offset of a pbuf may take the full first pbuf in a chain (resulting in the first pbuf having len==0)

This commit is contained in:
goldsimon 2009-02-18 16:50:40 +00:00
parent ea1eb45e3f
commit 7b6c11360f
2 changed files with 4 additions and 0 deletions

View File

@ -155,6 +155,9 @@
#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
#error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
#endif #endif
#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
#error "PBUF_POOL_BUFSIZE must be grater than MEM_ALIGNMENT or the offset may take the full first pbuf"
#endif
/* Compile-time checks for deprecated options. /* Compile-time checks for deprecated options.

View File

@ -200,6 +200,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", LWIP_ASSERT("check p->payload + p->len does not overflow pbuf",
((u8_t*)p->payload + p->len <= ((u8_t*)p->payload + p->len <=
(u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED));
LWIP_ASSERT("PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT", p->len != 0);
/* set reference count (needed here in case we fail) */ /* set reference count (needed here in case we fail) */
p->ref = 1; p->ref = 1;