fixed bug #41499 netconn::recv_avail can overflow

This commit is contained in:
Simon Goldschmidt 2014-02-20 21:55:11 +01:00
parent 08b56e8180
commit a2d6a50dff
3 changed files with 6 additions and 3 deletions

View File

@ -96,6 +96,9 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2014-02-20: Simon Goldschmidt
* api.h, sockets.c: fixed bug #41499 netconn::recv_avail can overflow
2014-01-08: Stathis Voukelatos 2014-01-08: Stathis Voukelatos
* memp_std.h: patch #7928 Fixed size calculation in MALLOC memory pool * memp_std.h: patch #7928 Fixed size calculation in MALLOC memory pool
creation macro creation macro

View File

@ -2521,7 +2521,7 @@ lwip_ioctl(int s, long cmd, void *argp)
u8_t val; u8_t val;
#if LWIP_SO_RCVBUF #if LWIP_SO_RCVBUF
u16_t buflen = 0; u16_t buflen = 0;
s16_t recv_avail; int recv_avail;
#endif /* LWIP_SO_RCVBUF */ #endif /* LWIP_SO_RCVBUF */
if (!sock) { if (!sock) {
@ -2565,7 +2565,7 @@ lwip_ioctl(int s, long cmd, void *argp)
if (recv_avail < 0) { if (recv_avail < 0) {
recv_avail = 0; recv_avail = 0;
} }
*((u16_t*)argp) = (u16_t)recv_avail; *((int*)argp) = recv_avail;
/* Check if there is data left from the last recv operation. /maq 041215 */ /* Check if there is data left from the last recv operation. /maq 041215 */
if (sock->lastdata) { if (sock->lastdata) {

View File

@ -203,7 +203,7 @@ struct netconn {
/** number of bytes currently in recvmbox to be received, /** number of bytes currently in recvmbox to be received,
tested against recv_bufsize to limit bytes on recvmbox tested against recv_bufsize to limit bytes on recvmbox
for UDP and RAW, used for FIONREAD */ for UDP and RAW, used for FIONREAD */
s16_t recv_avail; int recv_avail;
#endif /* LWIP_SO_RCVBUF */ #endif /* LWIP_SO_RCVBUF */
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */ /** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */
u8_t flags; u8_t flags;