lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] bug in netbuf_copy_partial


From: Jani Monoses
Subject: [lwip-users] [lwip] bug in netbuf_copy_partial
Date: Wed, 08 Jan 2003 22:23:38 -0000

Hi
in netbuf_copy_partial if the pbuf we start copying from is not the last
in the chain and the amount of data we copy is so the it needs going in
the next pbuf the first "offset" bytes will be lost from those pbufs.
So offset must be zeroed after finding the starting pbuf.
Since this is only used by lwip_recvfrom the fix is useful only for
socket users...
UDP calls this function but always with offset 0.



void
netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
{
        <snip>

  for(p = buf->p; left < len && p != NULL; p = p->next) {
    if(offset != 0 && offset >= p->len) {
      offset -= p->len;
    } else {
      for(i = offset; i < p->len; ++i) {

        offset = 0;     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        ((char *)dataptr)[left] = ((char *)p->payload)[i];
        if(++left >= len) {
          return;
        }
      }
    }
  }
}

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




reply via email to

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