lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] [lwip] Some Bugs?


From: H.J.W. .
Subject: [lwip-users] [lwip] Some Bugs?
Date: Wed, 08 Jan 2003 23:59:44 -0000

Hi!
I got a copy of your lightweight tcp/ip stack source from the Internet a 
few days ago, it is really nice.

Well, I have finished read the source and here I found two bugs in the 
source. I'm not sure, so I wrote to you, it is for your reference.

The first one:

In socket.c, the function :

int 
lwip_sendto(int s, void *data, int size, unsigned int flags,
       struct sockaddr *to, int tolen)
{
  struct lwip_socket *sock;
  struct ip_addr remote_addr, *addr;
  u16_t remote_port, port;
  int ret;

  sock = get_socket(s);
  if(sock == NULL) {
    return -1;
  }
  
  /* get the peer if currently connected */
  netconn_peer(sock->conn, &addr, &port);
  
  remote_addr.addr = ((struct sockaddr_in *)to)->sin_addr.s_addr;
  remote_port = ((struct sockaddr_in *)to)->sin_port;
  netconn_connect(sock->conn, &remote_addr, remote_port);
  
  ret = lwip_send(s, data, size, flags);

  /* reset the remote address and port number
     of the connection */
  netconn_connect(sock->conn, addr, port);
  return ret;
}

I notice that the pointer 'addr' JUST points to the 'remote_ip' of pcb 
after the call of netconn_peer, then the 'remote_ip' field of pcb was 
rewrited by the call of netconn_connect, so the second call of 
netconn_connect to reset the 'remote_ip' will be not effect, the previous 
connection infomation was lost!

The second one:

I notice that the tcp listen pcb struct is smaller than normal tcp pcb 
struct in order to save some memory, but in function
static void do_delconn(struct api_msg_msg *msg),
they are treated as the same size,and the code below will overwrite the 
memory field which does not belong to the tcp listen pcb.
      tcp_arg(msg->conn->pcb.tcp, NULL);
      tcp_sent(msg->conn->pcb.tcp, NULL); //here
      tcp_recv(msg->conn->pcb.tcp, NULL); //here
      tcp_accept(msg->conn->pcb.tcp, NULL);
      tcp_poll(msg->conn->pcb.tcp, NULL, 0);//here
      tcp_err(msg->conn->pcb.tcp, NULL);//here


Regards!
H.J.W
2002-10-21






_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.msn.com/lccn/ 

[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]