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
1=== modified file 'src/libecryptfs/key_management.c'
2--- src/libecryptfs/key_management.c 2013-10-27 16:52:03 +0000
3+++ src/libecryptfs/key_management.c 2014-02-28 15:04:17 +0000
4@@ -76,6 +76,9 @@
5 if (rc) {
6 syslog(LOG_ERR, "Error generating payload for auth tok key; "
7 "rc = [%d]\n", rc);
8+ memset(*auth_tok, 0, sizeof(struct ecryptfs_auth_tok));
9+ free(*auth_tok);
10+ *auth_tok = NULL;
11 rc = (rc < 0) ? rc : rc * -1;
12 goto out;
13 }
14
15=== modified file 'src/utils/mount.ecryptfs.c'
16--- src/utils/mount.ecryptfs.c 2013-10-27 22:33:19 +0000
17+++ src/utils/mount.ecryptfs.c 2014-02-28 15:04:17 +0000
18@@ -576,6 +576,12 @@
19 goto out;
20 }
21 mnt_params = malloc(sizeof(struct val_node));
22+ if (!mnt_params) {
23+ fprintf(stderr, "Unable to allocate memory for mount "
24+ "parameters buffer\n");
25+ rc = -ENOMEM;
26+ goto out;
27+ }
28 memset(mnt_params, 0, sizeof(struct val_node));
29 memset(&ctx, 0, sizeof(struct ecryptfs_ctx));
30 ctx.get_string = &get_string_stdin;

Subscribers

People subscribed via source and target branches