mirror of
https://github.com/esphome/esphome.git
synced 2026-09-15 00:58:40 +00:00
[api] Add safety check for full write in write_raw_iov_ before enqueue
When called directly (not via write_raw_fast_iov_), sent could equal total_write_len. Check before enqueueing to avoid a no-op enqueue.
This commit is contained in:
@@ -155,6 +155,10 @@ APIError APIFrameHelper::write_raw_iov_(const struct iovec *iov, int iovcnt, uin
|
||||
}
|
||||
}
|
||||
|
||||
// Full write completed (possible when called directly, not via write_raw_fast_iov_)
|
||||
if (sent == static_cast<ssize_t>(total_write_len))
|
||||
return APIError::OK;
|
||||
|
||||
// Queue unsent data into overflow buffer
|
||||
if (!this->overflow_buf_.enqueue_iov(iov, iovcnt, total_write_len, static_cast<uint16_t>(sent))) {
|
||||
HELPER_LOG("Overflow buffer full, dropping connection");
|
||||
|
||||
Reference in New Issue
Block a user