buglwIP - A Lightweight TCP/IP stack - Bugs: bug #40788, lwip_setsockopt_internal() crashes

 
 

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

bug #40788: lwip_setsockopt_internal() crashes

Submitter:  Andreas Haas <ah11088>
Submitted:  Tue 03 Dec 2013 02:36:25 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Crash Error Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.4.1

Sat 17 Jan 2015 01:32:31 PM UTC, comment #1: 

Fixed for (hopefully) all cases in set/getsockopt (NULL check was missing in many places).

Simon Goldschmidt <goldsimon>
Group administrator
Tue 03 Dec 2013 02:36:25 PM UTC, original submission:  

I’m using the lwIP (1.4.1) TCP socket interface on a board with a LPC1778 microcontroller to implement a server application.

One of my test cases is to connect() to the server and then again close() the socket immediately. When I do this lwip_setsockopt_internal() crashes.

I use LWIP_TCP_KEEPALIVE and do the corresponding setsockopt(SO_KEEPALIVE) operation directly after the accept(). This causes lwip_setsockopt_internal() to crash at line 2111 in src/api/sockets.c :

      if ((int)optval) {
        ip_set_option(sock->conn->pcb.ip, optname); /* <---- here it chrashes */
      } else {
        ip_reset_option(sock->conn->pcb.ip, optname);
      }

The reason is that sock->conn-pcb.ip is a NULL pointer.

My fix is to check for the NULL pointer and, if so, skip that code. Find attached a corresponding patch for all lwip_setsockopt_internal() options.


Please let me know what you think about the fix and if you plan to incorporate it in future lwIP versions.

Andreas Haas <ah11088>

 

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

Attached Files
file #29774:  lwip_setsockopt_internal.patch added by ah11088 (8KiB - application/octet-stream - Patch to in src/api/sockets.c )

 

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 ah11088 (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-01-17 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2013-12-03 ah11088 Attached File- Added lwip_setsockopt_internal.patch, #29774

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code