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
=== modified file 'configure.ac'
--- configure.ac 2013-06-11 13:26:48 +0000
+++ configure.ac 2013-07-05 15:55:29 +0000
@@ -37,7 +37,7 @@
37#37#
38# For more details:38# For more details:
39# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html39# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
40LIBECRYPTFS_LT_CURRENT="0"40LIBECRYPTFS_LT_CURRENT="1"
41LIBECRYPTFS_LT_REVISION="0"41LIBECRYPTFS_LT_REVISION="0"
42LIBECRYPTFS_LT_AGE="0"42LIBECRYPTFS_LT_AGE="0"
43AC_SUBST([LIBECRYPTFS_LT_CURRENT])43AC_SUBST([LIBECRYPTFS_LT_CURRENT])
4444
=== modified file 'src/daemon/main.c'
--- src/daemon/main.c 2012-11-02 14:31:32 +0000
+++ src/daemon/main.c 2013-07-05 15:55:29 +0000
@@ -210,7 +210,7 @@
210 exit(1);210 exit(1);
211 }211 }
212 for (fd=0; fd < 3; fd++) {212 for (fd=0; fd < 3; fd++) {
213 if (dup2(null, 0) == -1) {213 if (dup2(null, fd) == -1) {
214 syslog(LOG_ERR, "Failed to dup null: %m\n");214 syslog(LOG_ERR, "Failed to dup null: %m\n");
215 exit(1);215 exit(1);
216 }216 }
217217
=== modified file 'src/libecryptfs/cmd_ln_parser.c'
--- src/libecryptfs/cmd_ln_parser.c 2011-12-14 17:23:53 +0000
+++ src/libecryptfs/cmd_ln_parser.c 2013-07-05 15:55:29 +0000
@@ -239,7 +239,7 @@
239int process_comma_tok(struct ecryptfs_name_val_pair **current, char *tok,239int process_comma_tok(struct ecryptfs_name_val_pair **current, char *tok,
240 /*@null@*/ char *prefix)240 /*@null@*/ char *prefix)
241{241{
242 int tok_len = (int)strlen(tok);242 int tok_len;
243 char new_prefix[MAX_TOK_LEN];243 char new_prefix[MAX_TOK_LEN];
244 char sub_token[MAX_TOK_LEN];244 char sub_token[MAX_TOK_LEN];
245 char *name = NULL;245 char *name = NULL;
@@ -247,9 +247,10 @@
247 int i, j, st_len;247 int i, j, st_len;
248 int rc = 0;248 int rc = 0;
249249
250 if(tok && tok[0] == '\0') {250 if (!tok || (tok && tok[0] == '\0')) {
251 goto out;251 goto out;
252 }252 }
253 tok_len = (int)strlen(tok);
253 if (tok_len < 0 || tok_len > MAX_TOK_LEN) {254 if (tok_len < 0 || tok_len > MAX_TOK_LEN) {
254 rc = -EINVAL;255 rc = -EINVAL;
255 goto out;256 goto out;
@@ -304,10 +305,10 @@
304 memcpy(name, sub_token, i);305 memcpy(name, sub_token, i);
305 name[i] = '\0';306 name[i] = '\0';
306 } else {307 } else {
307 if((i-j) > 1) {308 if ((i-j) > 1) {
308 if (!(value = malloc(i - j + 1))) {309 if (!(value = malloc(i - j + 1))) {
309 rc = -ENOMEM;310 rc = -ENOMEM;
310 goto out;311 goto out_free_name;
311 }312 }
312 memcpy(value, &sub_token[j+1], (i - j));313 memcpy(value, &sub_token[j+1], (i - j));
313 value[(i - j)] = '\0';314 value[(i - j)] = '\0';
@@ -316,7 +317,7 @@
316 if (!((*current)->next =317 if (!((*current)->next =
317 malloc(sizeof(struct ecryptfs_name_val_pair)))) {318 malloc(sizeof(struct ecryptfs_name_val_pair)))) {
318 rc = -ENOMEM;319 rc = -ENOMEM;
319 goto out;320 goto out_free_value;
320 }321 }
321 memset((*current)->next, 0, sizeof(struct ecryptfs_name_val_pair));322 memset((*current)->next, 0, sizeof(struct ecryptfs_name_val_pair));
322 if (strlen(name) == 0) {323 if (strlen(name) == 0) {
@@ -328,6 +329,12 @@
328 (*current)->value = value;329 (*current)->value = value;
329 (*current)->next = NULL;330 (*current)->next = NULL;
330 }331 }
332 return rc;
333
334out_free_value:
335 free(value);
336out_free_name:
337 free(name);
331out:338out:
332 return rc;339 return rc;
333}340}
334341
=== modified file 'src/libecryptfs/decision_graph.c'
--- src/libecryptfs/decision_graph.c 2013-06-06 09:37:37 +0000
+++ src/libecryptfs/decision_graph.c 2013-07-05 15:55:29 +0000
@@ -143,24 +143,6 @@
143 return set_exit_param_node_for_node(param_node, exit_param_node, 1);143 return set_exit_param_node_for_node(param_node, exit_param_node, 1);
144}144}
145145
146/**
147 * set_exit_param_node_for_arr
148 *
149 * Sets the exit param node for all NULL transitions contained in an
150 * array of param nodes.
151 */
152int set_exit_param_node_for_arr(struct param_node param_node_arr[],
153 struct param_node *exit_param_node)
154{
155 int arr_len = sizeof(param_node_arr) / sizeof(param_node_arr[0]);
156 int i;
157
158 for (i = 0; i < arr_len; i++)
159 set_exit_param_node_for_node(&param_node_arr[i],
160 exit_param_node, 0);
161 return 0;
162}
163
164void ecryptfs_destroy_nvp(struct ecryptfs_name_val_pair *nvp)146void ecryptfs_destroy_nvp(struct ecryptfs_name_val_pair *nvp)
165{147{
166 return;148 return;
@@ -1155,7 +1137,7 @@
1155 tmp_tn->trans_func = &ecryptfs_enter_linear_subgraph_tf;1137 tmp_tn->trans_func = &ecryptfs_enter_linear_subgraph_tf;
1156 rc = 0;1138 rc = 0;
1157 param_node = NULL;1139 param_node = NULL;
1158 for (i = 0; i < num_params; i++) {1140 for (i = 0; params && i < num_params; i++) {
1159 if ((param_node = malloc(sizeof(struct param_node))) == NULL) {1141 if ((param_node = malloc(sizeof(struct param_node))) == NULL) {
1160 rc = -ENOMEM;1142 rc = -ENOMEM;
1161 goto out;1143 goto out;
11621144
=== modified file 'src/utils/mount.ecryptfs.c'
--- src/utils/mount.ecryptfs.c 2012-07-13 14:40:45 +0000
+++ src/utils/mount.ecryptfs.c 2013-07-05 15:55:29 +0000
@@ -343,21 +343,8 @@
343 next_opt++;343 next_opt++;
344 if (!strncmp(opt, option, option_len))344 if (!strncmp(opt, option, option_len))
345 return 1;345 return 1;
346 else {346 else
347 opt = next_opt;347 opt = next_opt;
348 continue;
349 }
350 if (!next_opt) {
351 if (opt != options)
352 end = --opt;
353 else
354 end = options;
355 *end = '\0';
356 break;
357 }
358 memcpy(opt, next_opt, end - next_opt);
359 end = end - (next_opt - opt);
360 *end = '\0';
361 }348 }
362 return 0;349 return 0;
363}350}
364351
=== modified file 'tests/kernel/trunc-file/test.c'
--- tests/kernel/trunc-file/test.c 2013-06-06 09:00:59 +0000
+++ tests/kernel/trunc-file/test.c 2013-07-05 15:55:29 +0000
@@ -256,6 +256,7 @@
256int main(int argc, char **argv)256int main(int argc, char **argv)
257{257{
258 ssize_t len = DEFAULT_SIZE;258 ssize_t len = DEFAULT_SIZE;
259 const ssize_t max_len = SSIZE_MAX / 1024;
259 int i;260 int i;
260 int ret;261 int ret;
261262
@@ -272,13 +273,11 @@
272 }273 }
273 }274 }
274275
275 len *= 1024;276 if (len > max_len) {
276 if (len > SSIZE_MAX) {277 fprintf(stderr, "size should be < %zd\n", max_len);
277 fprintf(stderr, "size should be < %zd\n", (ssize_t)SSIZE_MAX / 1024);
278 exit(TEST_ERROR);278 exit(TEST_ERROR);
279 }279 }
280
281 signal(SIGINT, sighandler);280 signal(SIGINT, sighandler);
282281
283 exit(test_exercise(argv[1], len));282 exit(test_exercise(argv[1], len * 1024));
284}283}

Subscribers

People subscribed via source and target branches