buglwIP - A Lightweight TCP/IP stack - Bugs: bug #57344, IS_SOCK_ADDR_ALIGNED(name) in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #57344: IS_SOCK_ADDR_ALIGNED(name) in sockets.c is 4-byte aligned, not aligned to MEM_ALIGNMENT

Submitter:  Victor Brzeski <vbrzeski>
Submitted:  Mon 02 Dec 2019 07:00:16 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Mon 02 Dec 2019 07:54:40 PM UTC, comment #1: 

Hmm, ok, on 16 bit architectures you have a problem here. I'm afraid our 16 bit support is not that well tested nowadays, where most platforms are 32 bit.

OTOH, I'm not sure MEM_ALIGNMENT is correct here: even platforms with MEM_ALIGNMENT of 8 may automatically align this to 4 since the biggest member is an u32_t.

I've changed it to:
#define IS_SOCK_ADDR_ALIGNED(name) ((((mem_ptr_t)(name)) % LWIP_MIN(4, MEM_ALIGNMENT)) == 0)

Simon Goldschmidt <goldsimon>
Group administrator
Mon 02 Dec 2019 07:00:16 PM UTC, original submission:  

As suggested, the socket API in sockets.c has a macro to detect misaligned socket addresses as so:

#define IS_SOCK_ADDR_ALIGNED(name) \
  ((((mem_ptr_t)(name)) % 4) == 0)

it seems it should be as so:

#define IS_SOCK_ADDR_ALIGNED(name) \
  ((((mem_ptr_t)(name)) % MEM_ALIGNMENT) == 0)

The effect is that my 16-bit system will not be able to allocate the sock addr on a normal alignment for my architecture. While there are work-arounds with arch.h, these induce tight-coupling to lwIP for my application code.


Victor Brzeski <vbrzeski>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by vbrzeski (Submitted the item)
  • -email is unavailable- added by vbrzeski
  • -email is unavailable- added by vbrzeski
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-02 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2019-12-02 vbrzeski Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code