Merge lp:~colin-king/ecryptfs/memleaks into lp:ecryptfs

Proposed by Colin Ian King
Status: Merged
Merged at revision: 829
Proposed branch: lp:~colin-king/ecryptfs/memleaks
Merge into: lp:ecryptfs
Diff against target: 30 lines (+9/-0)
2 files modified
src/libecryptfs/key_management.c (+3/-0)
src/utils/mount.ecryptfs.c (+6/-0)
To merge this branch: bzr merge lp:~colin-king/ecryptfs/memleaks
Reviewer Review Type Date Requested Status
eCryptfs Pending
Review via email: mp+208832@code.launchpad.net

Description of the change

A couple of minor fixes: Fix a memory leak and handle out of memory error, as found by using cppcheck.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/libecryptfs/key_management.c'
--- src/libecryptfs/key_management.c 2013-10-27 16:52:03 +0000
+++ src/libecryptfs/key_management.c 2014-02-28 15:04:17 +0000
@@ -76,6 +76,9 @@
76 if (rc) {76 if (rc) {
77 syslog(LOG_ERR, "Error generating payload for auth tok key; "77 syslog(LOG_ERR, "Error generating payload for auth tok key; "
78 "rc = [%d]\n", rc);78 "rc = [%d]\n", rc);
79 memset(*auth_tok, 0, sizeof(struct ecryptfs_auth_tok));
80 free(*auth_tok);
81 *auth_tok = NULL;
79 rc = (rc < 0) ? rc : rc * -1;82 rc = (rc < 0) ? rc : rc * -1;
80 goto out;83 goto out;
81 }84 }
8285
=== modified file 'src/utils/mount.ecryptfs.c'
--- src/utils/mount.ecryptfs.c 2013-10-27 22:33:19 +0000
+++ src/utils/mount.ecryptfs.c 2014-02-28 15:04:17 +0000
@@ -576,6 +576,12 @@
576 goto out;576 goto out;
577 }577 }
578 mnt_params = malloc(sizeof(struct val_node));578 mnt_params = malloc(sizeof(struct val_node));
579 if (!mnt_params) {
580 fprintf(stderr, "Unable to allocate memory for mount "
581 "parameters buffer\n");
582 rc = -ENOMEM;
583 goto out;
584 }
579 memset(mnt_params, 0, sizeof(struct val_node));585 memset(mnt_params, 0, sizeof(struct val_node));
580 memset(&ctx, 0, sizeof(struct ecryptfs_ctx));586 memset(&ctx, 0, sizeof(struct ecryptfs_ctx));
581 ctx.get_string = &get_string_stdin;587 ctx.get_string = &get_string_stdin;

Subscribers

People subscribed via source and target branches