X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt_common.c;h=705c7249903e2f4e998043e2a483029c43596809;hp=e02dc6af5b88ac5d5deb83f10d333324448c112a;hb=8c24d4e777f21a8773adfd028af26b967d1880ec;hpb=9de1287d67c9562e9140c6dc7deb0c01c4e10cc0 diff --git a/crypt_common.c b/crypt_common.c index e02dc6af..705c7249 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -11,8 +11,8 @@ #include "para.h" #include "error.h" #include "string.h" -#include "crypt_backend.h" #include "crypt.h" +#include "crypt_backend.h" /** If the key begins with this text, we treat it as an ssh key. */ #define KEY_TYPE_TXT "ssh-rsa" @@ -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, @@ -345,9 +350,12 @@ __printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc, { char *msg; int ret; + va_list ap; - PARA_VSPRINTF(fmt, msg); - ret = sc_send_buffer(scc, msg); + va_start(ap, fmt); + ret = xvasprintf(&msg, fmt, ap); + va_end(ap); + ret = sc_send_bin_buffer(scc, msg, ret); free(msg); return ret; }