From: Florian Forster Date: Wed, 7 Apr 2010 09:53:32 +0000 (+0200) Subject: network plugin: Fix a severe memory leak. X-Git-Tag: collectd-4.8.4~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=24b8995d6ffaba6e1ad59cc330938466454059e7;p=collectd.git network plugin: Fix a severe memory leak. A couple of bytes were leaked with every encrypted packet received. --- diff --git a/src/network.c b/src/network.c index a5305056..c34eb38e 100644 --- a/src/network.c +++ b/src/network.c @@ -1120,7 +1120,10 @@ static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */ cypher = network_get_aes256_cypher (se, pea.iv, sizeof (pea.iv), pea.username); if (cypher == NULL) + { + sfree (pea.username); return (-1); + } payload_len = part_size - (PART_ENCRYPTION_AES256_SIZE + username_len); assert (payload_len > 0); @@ -1132,6 +1135,7 @@ static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */ /* in = */ NULL, /* in len = */ 0); if (err != 0) { + sfree (pea.username); ERROR ("network plugin: gcry_cipher_decrypt returned: %s", gcry_strerror (err)); return (-1); @@ -1150,6 +1154,7 @@ static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */ buffer + buffer_offset, payload_len); if (memcmp (hash, pea.hash, sizeof (hash)) != 0) { + sfree (pea.username); ERROR ("network plugin: Decryption failed: Checksum mismatch."); return (-1); } @@ -1161,6 +1166,8 @@ static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */ *ret_buffer = buffer + part_size; *ret_buffer_len = buffer_len - part_size; + sfree (pea.username); + return (0); } /* }}} int parse_part_encr_aes256 */ /* #endif HAVE_LIBGCRYPT */