Wiznet / ioLibrary_Driver

ioLibrary_Driver can be used for the application design of WIZnet TCP/IP chips as W5500, W5300, W5200, W5100 W5100S.
MIT License
613 stars 331 forks source link

_WIZCHIP_ < W5200 : wizchip_init : Infinite loop when buffer size is set to 0 #44

Closed vanvught closed 6 years ago

vanvught commented 6 years ago

There are 2 lines with an infinite loop when there is a socket buffer set with zero size.

https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/wizchip_conf.c#L444 https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/wizchip_conf.c#L478

Test case:

#define _WIZCHIP_ 5100
#include "wizchip_conf.h"

uint8_t bufSize[2][4] = { {8,0,0,0},{8,0,0,0}};
wizchip_init(bufSize[0], bufSize[1]);

A possible fix can be:

while((txsize[i] >> j != 1) && (txsize[i] != 0)){j++;}
while((rxsize[i] >> j != 1) && (rxsize[i] != 0)){j++;}

With the above, j=0, therefore setSn_RXBUF_SIZE(i, j); will set a zero buffer size for that socket.

khj098765 commented 6 years ago

Oh! thank you for find bug. I will fix about this bug. thank you very much