File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,10 +96,19 @@ size_t SSLClient::write(const uint8_t *buf, size_t size) {
9696 if (m_debug >= DebugLevel::SSL_DUMP) Serial.write (buf, size);
9797 // check if the socket is still open and such
9898 if (!m_soft_connected (func_name) || !buf || !size) return 0 ;
99+ // wait until bearssl is ready to send
100+ if (m_run_until (BR_SSL_SENDAPP) < 0 ) {
101+ m_error (" Failed while waiting for the engine to enter BR_SSL_SENDAPP" , func_name);
102+ return 0 ;
103+ }
99104 // add to the bearssl io buffer, simply appending whatever we want to write
100105 size_t alen;
101106 unsigned char *br_buf = br_ssl_engine_sendapp_buf (&m_sslctx.eng , &alen);
102107 size_t cur_idx = 0 ;
108+ if (alen == 0 ) {
109+ m_error (" BearSSL returned zero length buffer for sending, did an internal error occur?" , func_name);
110+ return 0 ;
111+ }
103112 // while there are still elements to write
104113 while (cur_idx < size) {
105114 // if we're about to fill the buffer, we need to send the data and then wait
You can’t perform that action at this time.
0 commit comments