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

Proposed by Colin Ian King
Status: Merged
Merged at revision: 780
Proposed branch: lp:~colin-king/ecryptfs/minor-fixes
Merge into: lp:ecryptfs
Diff against target: 179 lines (+20/-45)
6 files modified
configure.ac (+1/-1)
src/daemon/main.c (+1/-1)
src/libecryptfs/cmd_ln_parser.c (+12/-5)
src/libecryptfs/decision_graph.c (+1/-19)
src/utils/mount.ecryptfs.c (+1/-14)
tests/kernel/trunc-file/test.c (+4/-5)
To merge this branch: bzr merge lp:~colin-king/ecryptfs/minor-fixes
Reviewer Review Type Date Requested Status
eCryptfs Pending
Review via email: mp+173234@code.launchpad.net

Description of the change

I've got around to sort out a few more issues found with Coverity Scan. I believe these are all minor bugs that aren't show stoppers, but need attention. I'd appreciate these being reviewed as I believe they are OK, but I'm not 100% sure I've touched all the changes with the testing I've done.

Thanks

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 'configure.ac'
2--- configure.ac 2013-06-11 13:26:48 +0000
3+++ configure.ac 2013-07-05 15:55:29 +0000
4@@ -37,7 +37,7 @@
5 #
6 # For more details:
7 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
8-LIBECRYPTFS_LT_CURRENT="0"
9+LIBECRYPTFS_LT_CURRENT="1"
10 LIBECRYPTFS_LT_REVISION="0"
11 LIBECRYPTFS_LT_AGE="0"
12 AC_SUBST([LIBECRYPTFS_LT_CURRENT])
13
14=== modified file 'src/daemon/main.c'
15--- src/daemon/main.c 2012-11-02 14:31:32 +0000
16+++ src/daemon/main.c 2013-07-05 15:55:29 +0000
17@@ -210,7 +210,7 @@
18 exit(1);
19 }
20 for (fd=0; fd < 3; fd++) {
21- if (dup2(null, 0) == -1) {
22+ if (dup2(null, fd) == -1) {
23 syslog(LOG_ERR, "Failed to dup null: %m\n");
24 exit(1);
25 }
26
27=== modified file 'src/libecryptfs/cmd_ln_parser.c'
28--- src/libecryptfs/cmd_ln_parser.c 2011-12-14 17:23:53 +0000
29+++ src/libecryptfs/cmd_ln_parser.c 2013-07-05 15:55:29 +0000
30@@ -239,7 +239,7 @@
31 int process_comma_tok(struct ecryptfs_name_val_pair **current, char *tok,
32 /*@null@*/ char *prefix)
33 {
34- int tok_len = (int)strlen(tok);
35+ int tok_len;
36 char new_prefix[MAX_TOK_LEN];
37 char sub_token[MAX_TOK_LEN];
38 char *name = NULL;
39@@ -247,9 +247,10 @@
40 int i, j, st_len;
41 int rc = 0;
42
43- if(tok && tok[0] == '\0') {
44+ if (!tok || (tok && tok[0] == '\0')) {
45 goto out;
46 }
47+ tok_len = (int)strlen(tok);
48 if (tok_len < 0 || tok_len > MAX_TOK_LEN) {
49 rc = -EINVAL;
50 goto out;
51@@ -304,10 +305,10 @@
52 memcpy(name, sub_token, i);
53 name[i] = '\0';
54 } else {
55- if((i-j) > 1) {
56+ if ((i-j) > 1) {
57 if (!(value = malloc(i - j + 1))) {
58 rc = -ENOMEM;
59- goto out;
60+ goto out_free_name;
61 }
62 memcpy(value, &sub_token[j+1], (i - j));
63 value[(i - j)] = '\0';
64@@ -316,7 +317,7 @@
65 if (!((*current)->next =
66 malloc(sizeof(struct ecryptfs_name_val_pair)))) {
67 rc = -ENOMEM;
68- goto out;
69+ goto out_free_value;
70 }
71 memset((*current)->next, 0, sizeof(struct ecryptfs_name_val_pair));
72 if (strlen(name) == 0) {
73@@ -328,6 +329,12 @@
74 (*current)->value = value;
75 (*current)->next = NULL;
76 }
77+ return rc;
78+
79+out_free_value:
80+ free(value);
81+out_free_name:
82+ free(name);
83 out:
84 return rc;
85 }
86
87=== modified file 'src/libecryptfs/decision_graph.c'
88--- src/libecryptfs/decision_graph.c 2013-06-06 09:37:37 +0000
89+++ src/libecryptfs/decision_graph.c 2013-07-05 15:55:29 +0000
90@@ -143,24 +143,6 @@
91 return set_exit_param_node_for_node(param_node, exit_param_node, 1);
92 }
93
94-/**
95- * set_exit_param_node_for_arr
96- *
97- * Sets the exit param node for all NULL transitions contained in an
98- * array of param nodes.
99- */
100-int set_exit_param_node_for_arr(struct param_node param_node_arr[],
101- struct param_node *exit_param_node)
102-{
103- int arr_len = sizeof(param_node_arr) / sizeof(param_node_arr[0]);
104- int i;
105-
106- for (i = 0; i < arr_len; i++)
107- set_exit_param_node_for_node(&param_node_arr[i],
108- exit_param_node, 0);
109- return 0;
110-}
111-
112 void ecryptfs_destroy_nvp(struct ecryptfs_name_val_pair *nvp)
113 {
114 return;
115@@ -1155,7 +1137,7 @@
116 tmp_tn->trans_func = &ecryptfs_enter_linear_subgraph_tf;
117 rc = 0;
118 param_node = NULL;
119- for (i = 0; i < num_params; i++) {
120+ for (i = 0; params && i < num_params; i++) {
121 if ((param_node = malloc(sizeof(struct param_node))) == NULL) {
122 rc = -ENOMEM;
123 goto out;
124
125=== modified file 'src/utils/mount.ecryptfs.c'
126--- src/utils/mount.ecryptfs.c 2012-07-13 14:40:45 +0000
127+++ src/utils/mount.ecryptfs.c 2013-07-05 15:55:29 +0000
128@@ -343,21 +343,8 @@
129 next_opt++;
130 if (!strncmp(opt, option, option_len))
131 return 1;
132- else {
133+ else
134 opt = next_opt;
135- continue;
136- }
137- if (!next_opt) {
138- if (opt != options)
139- end = --opt;
140- else
141- end = options;
142- *end = '\0';
143- break;
144- }
145- memcpy(opt, next_opt, end - next_opt);
146- end = end - (next_opt - opt);
147- *end = '\0';
148 }
149 return 0;
150 }
151
152=== modified file 'tests/kernel/trunc-file/test.c'
153--- tests/kernel/trunc-file/test.c 2013-06-06 09:00:59 +0000
154+++ tests/kernel/trunc-file/test.c 2013-07-05 15:55:29 +0000
155@@ -256,6 +256,7 @@
156 int main(int argc, char **argv)
157 {
158 ssize_t len = DEFAULT_SIZE;
159+ const ssize_t max_len = SSIZE_MAX / 1024;
160 int i;
161 int ret;
162
163@@ -272,13 +273,11 @@
164 }
165 }
166
167- len *= 1024;
168- if (len > SSIZE_MAX) {
169- fprintf(stderr, "size should be < %zd\n", (ssize_t)SSIZE_MAX / 1024);
170+ if (len > max_len) {
171+ fprintf(stderr, "size should be < %zd\n", max_len);
172 exit(TEST_ERROR);
173 }
174-
175 signal(SIGINT, sighandler);
176
177- exit(test_exercise(argv[1], len));
178+ exit(test_exercise(argv[1], len * 1024));
179 }

Subscribers

People subscribed via source and target branches