Fix bug in FIONREAD handling in LINUXMODE

Fix a bug in the socket API's ioctl for FIONREAD. If the socket's
lastdata was assigned the function returned without error but did not
update the argument pointer.

The cast type for argp was also changed to int to conform with the
other SO_RCVBUF handling.
This commit is contained in:
Joel Cunningham 2016-02-25 12:53:12 -06:00
parent fd891081c4
commit 2a8398dfb8

View File

@ -2621,18 +2621,20 @@ lwip_ioctl(int s, long cmd, void *argp)
struct pbuf *p;
if (sock->lastdata) {
p = ((struct netbuf *)sock->lastdata)->p;
*((int*)argp) = p->tot_len - sock->lastoffset;
} else {
struct netbuf *rxbuf;
err_t err;
if (sock->rcvevent <= 0) {
*((u16_t*)argp) = 0;
*((int*)argp) = 0;
} else {
err = netconn_recv(sock->conn, &rxbuf);
if (err != ERR_OK) {
*((u16_t*)argp) = 0;
*((int*)argp) = 0;
} else {
sock->lastdata = rxbuf;
*((u16_t*)argp) = rxbuf->p->tot_len;
sock->lastoffset = 0;
*((int*)argp) = rxbuf->p->tot_len;
}
}
}