Просмотр исходного кода

tun2socks: fix possible crash when tcp_close() is called from within lwip callbacks.
The problem is that tcp_close() may in certain cases immediately free the PCB, and we need to indicate such an event that to
the lwip code calling the callbacks by returning ERR_ABRT, or the code assumes the PCB survived. Fix by always returning
ERR_ABRT from callbacks if tcp_close() gets called. It appears that there are no ill effects if ERR_ABRT is returned even
though tcp_close() didn't immedietely free the PCB.

ambrop7 13 лет назад
Родитель
Сommit
65cdfeef06
1 измененных файлов с 2 добавлено и 6 удалено
  1. 2 6
      tun2socks/tun2socks.c

+ 2 - 6
tun2socks/tun2socks.c

@@ -1159,8 +1159,6 @@ int client_free_client (struct tcp_client *client)
 {
     ASSERT(!client->client_closed)
     
-    int was_abrt = 0;
-    
     // remove callbacks
     tcp_err(client->pcb, NULL);
     tcp_recv(client->pcb, NULL);
@@ -1170,14 +1168,12 @@ int client_free_client (struct tcp_client *client)
     err_t err = tcp_close(client->pcb);
     if (err != ERR_OK) {
         client_log(client, BLOG_ERROR, "tcp_close failed (%d)", err);
-        
         tcp_abort(client->pcb);
-        was_abrt = 1;
     }
     
-    client_handle_freed_client(client, was_abrt);
+    client_handle_freed_client(client, 1);
     
-    return was_abrt;
+    return 1;
 }
 
 void client_abort_client (struct tcp_client *client)