]> git.tue.mpg.de Git - paraslash.git/commitdiff
sc_send_bin_buffer: Use write_nonblock() rather than write_all().
authorAndre Noll <maan@systemlinux.org>
Sun, 11 Dec 2011 19:27:27 +0000 (20:27 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 20 Jan 2012 21:57:07 +0000 (22:57 +0100)
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
gcrypt.c

diff --git a/crypt.c b/crypt.c
index 7161e626119b5052689b03f161117c53004f6729..85ec091d76cf53e99f5bfc1e40eec9c735328a53 100644 (file)
--- 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;
 }
index 467e7399da721c5cb7ac6c0ea628f007052fea10..1ce4587f3d2e165a64e3d40991bfadf5264b47c6 100644 (file)
--- 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;
 }