~wlxing/ecryptfs/fix-command-termination

« back to all changes in this revision

Viewing changes to src/libecryptfs/decision_graph.c

  • Committer: Tyler Hicks
  • Author(s): Jason Xing
  • Date: 2017-06-08 00:19:21 UTC
  • Revision ID: tyhicks@canonical.com-20170608001921-rm497vizkpffmu95
Fix loop in ecryptfs-manager when there are no options (LP: #1695767)

Reproduce case:
1) User doesn't install openssl.
2) Run ecryptfs-manager and make selection 3.
It goes in the infinite loop...which means whatever selection you enter next
cannot end this command or alter your option.

Explanation for the patch:
Adding several lines to take such a case into consideration, through testing
whether "num_transitions" is set to zero or not we could prevent the infinite
loop. If it is set to zero, it will return -EINVAL because "num_transitions"
means how many options this command could show to users and zero means that
user has no option to choose.

[tyhicks: Print to stderr, adjust error message, and add changelog entry]

Show diffs side-by-side

added added

removed removed

Lines of Context:
462
462
                                       "VALS set\n", __FUNCTION__);
463
463
                        memset(&pe_head, 0, sizeof(pe_head));
464
464
                        pe = &pe_head;
 
465
                        if (!node->num_transitions) {
 
466
                                fprintf(stderr, "No options to display for [%s]\n",
 
467
                                        node->mnt_opt_names[0]);
 
468
                                rc = -EINVAL;
 
469
                                goto out;
 
470
                        }
465
471
                        if ((node->num_transitions == 1)
466
472
                            && !(node->flags
467
473
                                 & ECRYPTFS_PARAM_FORCE_DISPLAY_NODES)) {