X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=gcrypt.c;h=dbe4900862fef83a552d9c60d9ac21d4c8253d5e;hb=refs%2Fheads%2Fpu;hp=68f80f27fc30ff70fed05d5a7f7f8c89ef995260;hpb=c9d82ed7bf01e5fb21e530ba819915a984e9efc4;p=paraslash.git diff --git a/gcrypt.c b/gcrypt.c index 68f80f27..e5f64688 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -478,17 +478,20 @@ void apc_free_pubkey(struct asymmetric_key *key) free(key); } -static int decode_rsa(gcry_sexp_t sexp, unsigned char *outbuf, size_t *nbytes) +static int decode_rsa(gcry_sexp_t sexp, unsigned char **outbuf, size_t *nbytes) { const char *p = gcry_sexp_nth_data(sexp, 1, nbytes); - if (!p) + if (!p) { + *outbuf = NULL; return -E_RSA_DECODE; - memcpy(outbuf, p, *nbytes); + } + *outbuf = alloc(*nbytes); + memcpy(*outbuf, p, *nbytes); return 1; } -int apc_priv_decrypt(const char *key_file, unsigned char *outbuf, +int apc_priv_decrypt(const char *key_file, unsigned char **outbuf, unsigned char *inbuf, int inlen) { gcry_error_t gret; @@ -498,6 +501,7 @@ int apc_priv_decrypt(const char *key_file, unsigned char *outbuf, gcry_sexp_t in, out, priv_key; size_t nbytes; + *outbuf = NULL; ret = check_private_key_file(key_file); if (ret < 0) return ret;