]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - gcrypt.c
afs: Fix error handling of the select command.
[paraslash.git] / gcrypt.c
index ad38dcb83c56920a2e40116cccf6d6382fcad0b5..3c6c1ad1d74c234f56f289a46fad98cede2a5140 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -212,7 +212,7 @@ static int decode_key(const char *key_file, const char *header_str,
 
        ret = mmap_full_file(key_file, O_RDONLY, &map, &map_size, NULL);
        if (ret < 0)
-               return ret;
+               goto out;
        ret = -E_KEY_MARKER;
        if (strncmp(map, header_str, strlen(header_str)))
                goto unmap;
@@ -257,6 +257,7 @@ unmap:
                free(blob);
                blob = NULL;
        }
+out:
        *result = blob;
        return ret;
 }
@@ -582,6 +583,7 @@ static int get_asn_public_key(const char *key_file, struct asymmetric_key **resu
        }
        key = para_malloc(sizeof(*key));
        key->sexp = sexp;
+       key->num_bytes = n_size;
        *result = key;
        ret = n_size;
        PARA_INFO_LOG("successfully read %u bit asn public key\n", n_size * 8);
@@ -780,6 +782,9 @@ int priv_decrypt(const char *key_file, unsigned char *outbuf,
        gcry_sexp_t in, out, priv_key;
        size_t nbytes;
 
+       ret = check_key_file(key_file, true);
+       if (ret < 0)
+               return ret;
        PARA_INFO_LOG("decrypting %d byte input\n", inlen);
        /* key_file -> asymmetric key priv */
        ret = get_private_key(key_file, &priv);