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

Submitted by:  Andreas Haas <ah11088>
Submitted on:  Tue 03 Dec 2013 02:36:25 PM UTC  
 
Category: sockets/netconnSeverity: 3 - Normal
Item Group: Crash ErrorStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned 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>
Project AdministratorIn charge of this item.
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>

 

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
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by ah11088 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 17 Jan 2015 01:32:31 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed
    Tue 03 Dec 2013 02:36:25 PM UTCah11088Attached File-=>Added lwip_setsockopt_internal.patch, #29774

    Back to the top


    Powered by Savane 3.1-cleanup1