From 6a7ba04cacab72c9787c4b0427e36cedd5adefcf Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 11 Dec 2011 20:28:31 +0100 Subject: [PATCH] sc_send_buffer(): Return an error on short writes. This allows all callers to just check for negative return values. --- crypt_common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypt_common.c b/crypt_common.c index e02dc6af..4e9622e4 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -337,7 +337,12 @@ int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size) int sc_send_buffer(struct stream_cipher_context *scc, char *buf) { - return sc_send_bin_buffer(scc, buf, strlen(buf)); + size_t len = strlen(buf); + int ret = sc_send_bin_buffer(scc, buf, len); + + if (ret < 0 || ret == len) + return ret; + return -E_SHORT_WRITE; } __printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc, -- 2.39.2