[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Strange values appearing inside an LWIP packet buffer
From: |
Peter |
Subject: |
[lwip-users] Strange values appearing inside an LWIP packet buffer |
Date: |
Fri, 15 Jul 2022 08:51:07 +0100 |
Hi All,
Amazingly, I managed to catch one instance fairly quickly
https://peter-ftp.co.uk/screenshots/202207150014414908.jpg
The code is
> if ((!mem->used) &&
> (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) {
> /* mem is not used and at least perfect fit is possible:
> * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size'
> of mem */
>
> if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM
> + MIN_SIZE_ALIGNED)) {
> /* (in addition to the above, we test if another struct mem
> (SIZEOF_STRUCT_MEM) containing
> * at least MIN_SIZE_ALIGNED of data also fits in the 'user data
> space' of 'mem')
> * -> split large block, create empty remainder,
> * remainder must be large enough to contain MIN_SIZE_ALIGNED data:
> if
> * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size,
> * struct mem would fit in but no data between mem2 and mem2->next
> * @todo we could leave out MIN_SIZE_ALIGNED. We would create an
> empty
> * region that couldn't hold data, but when mem->next gets
> freed,
> * the 2 regions would be combined, resulting in more free
> memory
> */
> ptr2 = ptr + SIZEOF_STRUCT_MEM + size;
> /* create mem2 struct */
> mem2 = (struct mem *)(void *)&ram[ptr2];
> mem2->used = 0;
> mem2->next = mem->next;
> mem2->prev = ptr;
so it looks genuine. It does suggest that the PBUFs are used for stuff
other than packet data. Some sort of struct is being filled-in.
Strange place for it though.
Peter