From: Andre Noll Date: Thu, 16 Nov 2017 01:18:50 +0000 (+0100) Subject: crypt.c: Plug memory leak in get_public_key(). X-Git-Tag: v0.6.2~49 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=129ce40eff6bc09734a82280dec61827b5342759;p=paraslash.git crypt.c: Plug memory leak in get_public_key(). If server.users refers to an existing file which is not a ssh public key, we leak 4 bytes of memory: ==27302== 4 bytes in 1 blocks are definitely lost in loss record 1 of 8 ==27302== at 0x402C201: malloc (vg_replace_malloc.c:299) ==27302== by 0x8052FF3: para_malloc (string.c:63) ==27302== by 0x8066532: get_public_key (crypt.c:151) ==27302== by 0x80569D1: user_list_init (user_list.c:90) ==27302== by 0x804D74D: parse_config_or_die (server.c:279) ==27302== by 0x804C719: server_init (server.c:554) ==27302== by 0x804C719: main (server.c:655) Furtunately, this issue is trivial to fix. --- diff --git a/crypt.c b/crypt.c index 2af3fd7e..b8a587cd 100644 --- a/crypt.c +++ b/crypt.c @@ -154,8 +154,8 @@ int get_public_key(const char *key_file, struct asymmetric_key **result) goto out; ret = is_ssh_rsa_key(map, map_size); if (!ret) { - para_munmap(map, map_size); - return -E_SSH_PARSE; + ret = -E_SSH_PARSE; + goto out_unmap; } cp = map + ret; encoded_size = map_size - ret;