mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Fix bug #54327: V2.1.0rc1 pbuf.c misses stdint.h include
This commit is contained in:
parent
cd1dd4f5b1
commit
4e74421dac
@ -70,13 +70,13 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/sys.h"
|
||||
#if LWIP_TCP && TCP_QUEUE_OOSEQ
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
#endif
|
||||
@ -101,12 +101,14 @@ pbuf_skip_const(const struct pbuf *in, u16_t in_offset, u16_t *out_offset);
|
||||
#if !NO_SYS
|
||||
#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL
|
||||
#include "lwip/tcpip.h"
|
||||
#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \
|
||||
#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() \
|
||||
do { \
|
||||
if (tcpip_try_callback(pbuf_free_ooseq_callback, NULL) != ERR_OK) { \
|
||||
SYS_ARCH_PROTECT(old_level); \
|
||||
pbuf_free_ooseq_pending = 0; \
|
||||
SYS_ARCH_UNPROTECT(old_level); \
|
||||
} } while(0)
|
||||
} \
|
||||
} while (0)
|
||||
#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
@ -251,10 +253,9 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
return NULL;
|
||||
}
|
||||
qlen = LWIP_MIN(rem_len, (u16_t)(PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)));
|
||||
pbuf_init_alloced_pbuf(q, LWIP_MEM_ALIGN((void *)((u8_t *)q + SIZEOF_STRUCT_PBUF + offset)),
|
||||
rem_len, qlen, type, 0);
|
||||
LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned",
|
||||
((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0);
|
||||
pbuf_init_alloced_pbuf(
|
||||
q, LWIP_MEM_ALIGN((void *)((u8_t *)q + SIZEOF_STRUCT_PBUF + offset)), rem_len, qlen, type, 0);
|
||||
LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0);
|
||||
LWIP_ASSERT("PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT",
|
||||
(PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)) > 0);
|
||||
if (p == NULL) {
|
||||
@ -275,8 +276,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
mem_size_t alloc_len = (mem_size_t)(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF) + payload_len);
|
||||
|
||||
/* bug #50040: Check for integer overflow when calculating alloc_len */
|
||||
if ((payload_len < LWIP_MEM_ALIGN_SIZE(length)) ||
|
||||
(alloc_len < LWIP_MEM_ALIGN_SIZE(length))) {
|
||||
if ((payload_len < LWIP_MEM_ALIGN_SIZE(length)) || (alloc_len < LWIP_MEM_ALIGN_SIZE(length))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -285,10 +285,9 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
pbuf_init_alloced_pbuf(p, LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)),
|
||||
length, length, type, 0);
|
||||
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",
|
||||
((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
|
||||
pbuf_init_alloced_pbuf(
|
||||
p, LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)), length, length, type, 0);
|
||||
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -331,16 +330,15 @@ pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type)
|
||||
/* only allocate memory for the pbuf structure */
|
||||
p = (struct pbuf *)memp_malloc(MEMP_PBUF);
|
||||
if (p == NULL) {
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("pbuf_alloc_reference: Could not allocate MEMP_PBUF for PBUF_%s.\n",
|
||||
(type == PBUF_ROM) ? "ROM" : "REF"));
|
||||
LWIP_DEBUGF(
|
||||
PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("pbuf_alloc_reference: Could not allocate MEMP_PBUF for PBUF_%s.\n", (type == PBUF_ROM) ? "ROM" : "REF"));
|
||||
return NULL;
|
||||
}
|
||||
pbuf_init_alloced_pbuf(p, payload, length, length, type, 0);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
#if LWIP_SUPPORT_CUSTOM_PBUF
|
||||
/**
|
||||
* @ingroup pbuf
|
||||
@ -360,15 +358,20 @@ pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type)
|
||||
* big enough to hold 'length' plus the header size
|
||||
*/
|
||||
struct pbuf *
|
||||
pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p,
|
||||
void *payload_mem, u16_t payload_mem_len)
|
||||
pbuf_alloced_custom(pbuf_layer l,
|
||||
u16_t length,
|
||||
pbuf_type type,
|
||||
struct pbuf_custom *p,
|
||||
void *payload_mem,
|
||||
u16_t payload_mem_len)
|
||||
{
|
||||
u16_t offset = (u16_t)l;
|
||||
void *payload;
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloced_custom(length=%" U16_F ")\n", length));
|
||||
|
||||
if (LWIP_MEM_ALIGN_SIZE(offset) + length > payload_mem_len) {
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_WARNING, ("pbuf_alloced_custom(length=%"U16_F") buffer too short\n", length));
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_WARNING,
|
||||
("pbuf_alloced_custom(length=%" U16_F ") buffer too short\n", length));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -455,7 +458,6 @@ pbuf_realloc(struct pbuf *p, u16_t new_len)
|
||||
}
|
||||
/* q is last packet in chain */
|
||||
q->next = NULL;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -500,7 +502,8 @@ pbuf_add_header_impl(struct pbuf *p, size_t header_size_increment, u8_t force)
|
||||
if ((u8_t *)payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) {
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE,
|
||||
("pbuf_add_header: failed as %p < %p (not enough space for new header size)\n",
|
||||
(void *)payload, (void *)((u8_t *)p + SIZEOF_STRUCT_PBUF)));
|
||||
(void *)payload,
|
||||
(void *)((u8_t *)p + SIZEOF_STRUCT_PBUF)));
|
||||
/* bail out unsuccessfully */
|
||||
return 1;
|
||||
}
|
||||
@ -515,15 +518,15 @@ pbuf_add_header_impl(struct pbuf *p, size_t header_size_increment, u8_t force)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_add_header: old %p new %p (%"U16_F")\n",
|
||||
(void *)p->payload, (void *)payload, increment_magnitude));
|
||||
LWIP_DEBUGF(
|
||||
PBUF_DEBUG | LWIP_DBG_TRACE,
|
||||
("pbuf_add_header: old %p new %p (%" U16_F ")\n", (void *)p->payload, (void *)payload, increment_magnitude));
|
||||
|
||||
/* modify pbuf fields */
|
||||
p->payload = payload;
|
||||
p->len = (u16_t)(p->len + increment_magnitude);
|
||||
p->tot_len = (u16_t)(p->tot_len + increment_magnitude);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -606,8 +609,9 @@ pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
|
||||
p->len = (u16_t)(p->len - increment_magnitude);
|
||||
p->tot_len = (u16_t)(p->tot_len - increment_magnitude);
|
||||
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_remove_header: old %p new %p (%"U16_F")\n",
|
||||
(void *)payload, (void *)p->payload, increment_magnitude));
|
||||
LWIP_DEBUGF(
|
||||
PBUF_DEBUG | LWIP_DBG_TRACE,
|
||||
("pbuf_remove_header: old %p new %p (%" U16_F ")\n", (void *)payload, (void *)p->payload, increment_magnitude));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -731,8 +735,7 @@ pbuf_free(struct pbuf *p)
|
||||
if (p == NULL) {
|
||||
LWIP_ASSERT("p != NULL", p != NULL);
|
||||
/* if assertions are disabled, proceed with debug output */
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("pbuf_free(p == NULL) was called.\n"));
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("pbuf_free(p == NULL) was called.\n"));
|
||||
return 0;
|
||||
}
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p));
|
||||
@ -789,7 +792,8 @@ pbuf_free(struct pbuf *p)
|
||||
/* p->ref > 0, this pbuf is still referenced to */
|
||||
/* (and so the remaining pbufs in chain as well) */
|
||||
} else {
|
||||
LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, (u16_t)ref));
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE,
|
||||
("pbuf_free: %p has ref %" U16_F ", ending here.\n", (void *)p, (u16_t)ref));
|
||||
/* stop walking through the chain */
|
||||
p = NULL;
|
||||
}
|
||||
@ -854,8 +858,7 @@ pbuf_cat(struct pbuf *h, struct pbuf *t)
|
||||
{
|
||||
struct pbuf *p;
|
||||
|
||||
LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)",
|
||||
((h != NULL) && (t != NULL)), return;);
|
||||
LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)", ((h != NULL) && (t != NULL)), return;);
|
||||
|
||||
/* proceed to last pbuf of chain */
|
||||
for (p = h; p->next != NULL; p = p->next) {
|
||||
@ -962,12 +965,12 @@ pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
|
||||
{
|
||||
size_t offset_to = 0, offset_from = 0, len;
|
||||
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n",
|
||||
(const void *)p_to, (const void *)p_from));
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n", (const void *)p_to, (const void *)p_from));
|
||||
|
||||
/* is the target big enough to hold the source? */
|
||||
LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) &&
|
||||
(p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;);
|
||||
LWIP_ERROR("pbuf_copy: target not big enough to hold source",
|
||||
((p_to != NULL) && (p_from != NULL) && (p_to->tot_len >= p_from->tot_len)),
|
||||
return ERR_ARG;);
|
||||
|
||||
/* iterate through pbuf chain */
|
||||
do {
|
||||
@ -998,13 +1001,11 @@ pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
|
||||
|
||||
if ((p_from != NULL) && (p_from->len == p_from->tot_len)) {
|
||||
/* don't copy more than one packet! */
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!",
|
||||
(p_from->next == NULL), return ERR_VAL;);
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!", (p_from->next == NULL), return ERR_VAL;);
|
||||
}
|
||||
if ((p_to != NULL) && (p_to->len == p_to->tot_len)) {
|
||||
/* don't copy more than one packet! */
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!",
|
||||
(p_to->next == NULL), return ERR_VAL;);
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!", (p_to->next == NULL), return ERR_VAL;);
|
||||
}
|
||||
} while (p_from);
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy: end of chain reached.\n"));
|
||||
@ -1074,7 +1075,7 @@ void *
|
||||
pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset)
|
||||
{
|
||||
const struct pbuf *q;
|
||||
uint16_t out_offset;
|
||||
u16_t out_offset;
|
||||
|
||||
LWIP_ERROR("pbuf_get_contiguous: invalid buf", (p != NULL), return NULL;);
|
||||
LWIP_ERROR("pbuf_get_contiguous: invalid dataptr", (buffer != NULL), return NULL;);
|
||||
@ -1110,7 +1111,8 @@ pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t le
|
||||
* @param p the pbuf queue to be split
|
||||
* @param rest pointer to store the remainder (after the first 64K)
|
||||
*/
|
||||
void pbuf_split_64k(struct pbuf *p, struct pbuf **rest)
|
||||
void
|
||||
pbuf_split_64k(struct pbuf *p, struct pbuf **rest)
|
||||
{
|
||||
*rest = NULL;
|
||||
if ((p != NULL) && (p->next != NULL)) {
|
||||
@ -1132,8 +1134,7 @@ void pbuf_split_64k(struct pbuf *p, struct pbuf **rest)
|
||||
/* Update the tot_len field in the first part */
|
||||
for (i = p; i != NULL; i = i->next) {
|
||||
i->tot_len = (u16_t)(i->tot_len - r->tot_len);
|
||||
LWIP_ASSERT("tot_len/len mismatch in last pbuf",
|
||||
(i->next != NULL) || (i->tot_len == i->len));
|
||||
LWIP_ASSERT("tot_len/len mismatch in last pbuf", (i->next != NULL) || (i->tot_len == i->len));
|
||||
}
|
||||
if (p->flags & PBUF_FLAG_TCP_FIN) {
|
||||
r->flags |= PBUF_FLAG_TCP_FIN;
|
||||
@ -1331,8 +1332,7 @@ pbuf_clone(pbuf_layer layer, pbuf_type type, struct pbuf *p)
|
||||
* within the (first) pbuf (no pbuf queues!)
|
||||
*/
|
||||
err_t
|
||||
pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
|
||||
u16_t len, u16_t *chksum)
|
||||
pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, u16_t len, u16_t *chksum)
|
||||
{
|
||||
u32_t acc;
|
||||
u16_t copy_chksum;
|
||||
|
Loading…
Reference in New Issue
Block a user