Merge lp:~colin-king/ecryptfs/coverity-fixes into lp:ecryptfs

Proposed by Colin Ian King
Status: Merged
Merged at revision: 791
Proposed branch: lp:~colin-king/ecryptfs/coverity-fixes
Merge into: lp:ecryptfs
Diff against target: 88 lines (+24/-11)
3 files modified
src/key_mod/ecryptfs_key_mod_passphrase.c (+7/-6)
src/libecryptfs/main.c (+11/-1)
src/pam_ecryptfs/pam_ecryptfs.c (+6/-4)
To merge this branch: bzr merge lp:~colin-king/ecryptfs/coverity-fixes
Reviewer Review Type Date Requested Status
eCryptfs Pending
Review via email: mp+190436@code.launchpad.net

Description of the change

Some more fixes. 4 more minor miscellaneous fixes: memory leak, error checking, etc.

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/key_mod/ecryptfs_key_mod_passphrase.c'
2--- src/key_mod/ecryptfs_key_mod_passphrase.c 2009-04-21 19:50:44 +0000
3+++ src/key_mod/ecryptfs_key_mod_passphrase.c 2013-10-10 17:33:39 +0000
4@@ -51,12 +51,6 @@
5 struct ecryptfs_name_val_pair *walker;
6 int rc = 0;
7
8- file_head = malloc(sizeof(struct ecryptfs_name_val_pair));
9- if (!file_head) {
10- rc = -ENOMEM;
11- goto out;
12- }
13- memset(file_head, 0, sizeof(struct ecryptfs_name_val_pair));
14 if (strcmp(node->mnt_opt_names[0], "passphrase_passwd_file") == 0) {
15 fd = open(node->val, O_RDONLY);
16 if (fd == -1) {
17@@ -73,6 +67,13 @@
18 rc = MOUNT_ERROR;
19 goto out;
20 }
21+ file_head = malloc(sizeof(struct ecryptfs_name_val_pair));
22+ if (!file_head) {
23+ close(fd);
24+ rc = -ENOMEM;
25+ goto out;
26+ }
27+ memset(file_head, 0, sizeof(struct ecryptfs_name_val_pair));
28 rc = parse_options_file(fd, file_head);
29 close(fd);
30 if (rc) {
31
32=== modified file 'src/libecryptfs/main.c'
33--- src/libecryptfs/main.c 2013-06-06 09:21:51 +0000
34+++ src/libecryptfs/main.c 2013-10-10 17:33:39 +0000
35@@ -125,7 +125,9 @@
36 mnt = mnt_default;
37 } else {
38 /* Ensure that mnt doesn't contain newlines */
39- mnt = strtok(mnt, "\n");
40+ char *nl = strchr(mnt, '\n');
41+ if (nl)
42+ *nl = '\0';
43 }
44 fclose(fh);
45 }
46@@ -497,6 +499,14 @@
47 else {
48 char *shm_virt;
49
50+ if (rc == -1) {
51+ syslog(LOG_ERR, "Error allocating shared memory; "
52+ "errno string = [%m]\n");
53+ rc = -EIO;
54+ zombie_semaphore_unlock((*sem_id));
55+ goto out;
56+ }
57+
58 (*shm_id) = rc;
59 shm_virt = shmat((*shm_id), NULL, 0);
60 if (shm_virt == (void *)-1) {
61
62=== modified file 'src/pam_ecryptfs/pam_ecryptfs.c'
63--- src/pam_ecryptfs/pam_ecryptfs.c 2013-10-04 12:18:56 +0000
64+++ src/pam_ecryptfs/pam_ecryptfs.c 2013-10-10 17:33:39 +0000
65@@ -152,8 +152,9 @@
66 goto out;
67 }
68
69- if ((oeuid = geteuid()) < 0 || (oegid = getegid()) < 0 ||
70- (ngids = getgroups(sizeof(groups)/sizeof(gid_t), groups)) < 0) {
71+ oeuid = geteuid();
72+ oegid = getegid();
73+ if ((ngids = getgroups(sizeof(groups)/sizeof(gid_t), groups)) < 0) {
74 syslog(LOG_ERR, "pam_ecryptfs: geteuid error");
75 goto outnouid;
76 }
77@@ -455,8 +456,9 @@
78 goto out;
79 }
80
81- if ((oeuid = geteuid()) < 0 || (oegid = getegid()) < 0 ||
82- (ngids = getgroups(sizeof(groups)/sizeof(gid_t), groups)) < 0) {
83+ oeuid = geteuid();
84+ oegid = getegid();
85+ if ((ngids = getgroups(sizeof(groups)/sizeof(gid_t), groups)) < 0) {
86 syslog(LOG_ERR, "pam_ecryptfs: geteuid error");
87 goto outnouid;
88 }

Subscribers

People subscribed via source and target branches