iostream: protect write side against bad custom IO interfaces too

This is the same as the previous commit, just for the write side error
handling.

If we have a bad custom IO low-level driver that returns
DC_STATUS_SUCCESS with zero bytes written, and we have a write() user
that isn't ready for partial writes, we just consider that an IO error.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2020-03-13 11:48:35 -07:00
parent b77e7b6b21
commit 7882ba423c

View File

@ -260,6 +260,9 @@ dc_iostream_write (dc_iostream_t *iostream, const void *data, size_t size, size_
if (status != DC_STATUS_SUCCESS)
return status;
if (!nbytes)
return DC_STATUS_IO;
data = (void *)(nbytes + (char *)data);
size -= nbytes;
}