Skip to content

Commit

Permalink
WiFiClientSecure rx overflow fixes
Browse files Browse the repository at this point in the history
- Increase plaintext rx buffer size to 4096
- Request more data from axtls only when rx buffer is empty
  • Loading branch information
igrr committed Nov 15, 2015
1 parent defc049 commit 77428ba
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libraries/ESP8266WiFi/src/WiFiClientSecure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern "C"
#define SSL_DEBUG_OPTS 0
#endif

#define SSL_RX_BUF_SIZE 1536
#define SSL_RX_BUF_SIZE 4096

class SSLContext {
public:
Expand Down Expand Up @@ -92,10 +92,12 @@ class SSLContext {
}

int read(uint8_t* dst, size_t size) {
if (size > _rxbuf->getSize()) {
if (!_rxbuf->getSize()) {
_readAll();
}
return _rxbuf->read(reinterpret_cast<char*>(dst), size);
size_t available = _rxbuf->getSize();
size_t will_read = (available < size) ? available : size;
return _rxbuf->read(reinterpret_cast<char*>(dst), will_read);
}

int read() {
Expand Down

0 comments on commit 77428ba

Please sign in to comment.