BearSSLClient::write fails to send data buffer > 512 bytes
pennam opened this issue · comments
Mattia Pennasilico commented
Opened to track this issue arduino-libraries/ArduinoBearSSL#60 and related PR arduino-libraries/ArduinoBearSSL#61
Jeroen88 commented
The problem is here:
- If more than 512 bytes are written, then result == 512. In the next 'while' round, size is still it's original value, which is incorrect. This is working:
size_t BearSSLClient::write(const uint8_t *buf, size_t size)
{
size_t written = 0;
size_t toWrite = size;
while (written < toWrite) {
int result = br_sslio_write(&_ioc, buf, size);
if (result < 0) {
break;
}
buf += result;
written += result;
size -= result;
}
if (written == toWrite && br_sslio_flush(&_ioc) < 0) {
return 0;
}
return written;
}