From 3061192193ede6fccb04e947b19a4b573199f751 Mon Sep 17 00:00:00 2001 From: "git@daemon.de" Date: Mon, 22 Dec 2014 16:23:38 +0100 Subject: [PATCH] fail if trying to encrypt using an empty input buffer --- libpcp/crypto.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libpcp/crypto.c b/libpcp/crypto.c index 9032887..6a2e035 100644 --- a/libpcp/crypto.c +++ b/libpcp/crypto.c @@ -437,6 +437,14 @@ size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, byte * byte *hash = NULL; byte head[1]; + if(in->is_buffer) { + if(buffer_size(in->b) == 0) { + /* FIXME: add a ps_stream function for this */ + fatal(ptx, "Empty input stream buffer at %p!\n", in->b); + return 0; + } + } + if(recsign != NULL) { st = ucmalloc(sizeof(crypto_generichash_state)); hash = ucmalloc(crypto_generichash_BYTES_MAX);