Rename write_nonblock() to xwrite().
[paraslash.git] / crypt.c
diff --git a/crypt.c b/crypt.c
index 207ad5db4e9f264091076d404adb06e12b95e8e4..f33f769f6f035c18946c21fea064b37052802583 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -7,7 +7,6 @@
 /** \file crypt.c Openssl-based encryption/decryption routines. */
 
 #include <regex.h>
-#include <stdbool.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <openssl/rand.h>
@@ -299,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 = xwrite(scc->fd, (char *)tmp, len);
        free(tmp);
        return ret;
 }
@@ -307,7 +306,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf,
 int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf,
                size_t size)
 {
-       unsigned char *tmp = para_malloc(size);
+       unsigned char *tmp = para_malloc(ROUND_UP(size, RC4_ALIGN));
        ssize_t ret = recv(scc->fd, tmp, size, 0);
 
        if (ret > 0)