Merge lp:~tyhicks/ecryptfs/cid1375979 into lp:ecryptfs

Proposed by Tyler Hicks on 2017-06-09
Status: Merged
Merged at revision: 894
Proposed branch: lp:~tyhicks/ecryptfs/cid1375979
Merge into: lp:ecryptfs
Diff against target: 12 lines (+0/-2)
1 file modified
src/libecryptfs/cmd_ln_parser.c (+0/-2)
To merge this branch: bzr merge lp:~tyhicks/ecryptfs/cid1375979
Reviewer Review Type Date Requested Status
Jason Xing (community) 2017-06-09 Approve on 2017-06-09
Review via email: mp+325401@code.launchpad.net

Description of the Change

Remove unreachable code when parsing mount opt name value pairs

Revision 886 introduced a change to the mount option parsing code for
name-value pairs. A break was added to a loop once the first '=' is seen.
Before the break was added, it was possible that a '=' would be seen, then
memory allocated for the name portion of the string, then another '=' could be
seen and the previous name string be freed and then reallocated. However,
there's no longer a chance of needed to reallocate the name string so the
free() is not needed.

Discovered by Coverity (CID 1375979)

To post a comment you must log in.
Jason Xing (wlxing) wrote :

Thanks, Tyler.

You're right. We don't need to reallocate the memory for previous name string because we "break" the loop if we match the first "=". So the patch looks good for me :)

review: Approve
Tyler Hicks (tyhicks) wrote :

Thanks for the review!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/libecryptfs/cmd_ln_parser.c'
2--- src/libecryptfs/cmd_ln_parser.c 2017-05-25 21:22:24 +0000
3+++ src/libecryptfs/cmd_ln_parser.c 2017-06-09 15:33:38 +0000
4@@ -288,8 +288,6 @@
5 j = 0;
6 for (i = 0; i < st_len; i++)
7 if (sub_token[i] == '=') {
8- if (name)
9- free(name);
10 if (!(name = malloc(i + 1))) {
11 rc = -ENOMEM;
12 goto out;

Subscribers

People subscribed via source and target branches