From 6934fc28976594d0eb387bfef25cb938c677814c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 11 Dec 2011 20:27:27 +0100 Subject: [PATCH] sc_send_bin_buffer: Use write_nonblock() rather than write_all(). The write_nonblock() variant is safer here as it allows to let the callers deal with short writes. Despite the name, write_nonblock() can be used for both blocking and non-blocking fds. It will be renamed in a subsequent patch. --- crypt.c | 2 +- gcrypt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypt.c b/crypt.c index 7161e626..85ec091d 100644 --- a/crypt.c +++ b/crypt.c @@ -298,7 +298,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, memcpy(remainder, buf + l1, len - l1); RC4(&scc->send->key, len - l1, remainder, tmp + l1); } - ret = write_all(scc->fd, (char *)tmp, len); + ret = write_nonblock(scc->fd, (char *)tmp, len); free(tmp); return ret; } diff --git a/gcrypt.c b/gcrypt.c index 467e7399..1ce4587f 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -951,7 +951,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, gret = gcry_cipher_encrypt(scc->send->handle, tmp, size, (unsigned char *)buf, size); assert(gret == 0); - ret = write_all(scc->fd, (char *)tmp, size); + ret = write_nonblock(scc->fd, (char *)tmp, size); free(tmp); return ret; } -- 2.39.2