From 6f24630aa6d5ea343f0f0626b356d03fa36f890e Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 15 Aug 2011 20:05:11 +0200 Subject: [PATCH] crypt: Streamline get_asymmetric_key(). The clang analyzer says crypt.c:202:9: warning: Function call argument is an uninitialized value ret2 = para_munmap(map, map_size); ^ ~~~~~~~~ And right it is. This is not a bug though as map_size is only undefined if map is NULL and in this case para_munmap does not look at its second argument. However, this is rather subtle, so introduce a new label out_unmap and jump there only if we really must unmap the file. --- crypt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crypt.c b/crypt.c index 5b7029d3..207ad5db 100644 --- a/crypt.c +++ b/crypt.c @@ -184,24 +184,25 @@ int get_asymmetric_key(const char *key_file, int private, PARA_INFO_LOG("decoding public rsa-ssh key %s\n", key_file); ret = -ERRNO_TO_PARA_ERROR(EOVERFLOW); if (map_size > INT_MAX / 4) - goto out; + goto out_unmap; blob_size = 2 * map_size; blob = para_malloc(blob_size); ret = uudecode(cp, blob, blob_size); if (ret < 0) - goto out; + goto out_unmap; decoded_size = ret; ret = check_ssh_key_header(blob, decoded_size); if (ret < 0) - goto out; + goto out_unmap; ret = read_rsa_bignums(blob + ret, decoded_size - ret, &key->rsa); if (ret < 0) - goto out; + goto out_unmap; ret = RSA_size(key->rsa); -out: +out_unmap: ret2 = para_munmap(map, map_size); if (ret >= 0 && ret2 < 0) ret = ret2; +out: if (ret < 0) { free(key); *result = NULL; -- 2.30.2