Merge lp:~colin-king/ecryptfs/misc-ecryptfs-fixes-dec-2015 into lp:ecryptfs

Proposed by Colin Ian King
Status: Merged
Merged at revision: 869
Proposed branch: lp:~colin-king/ecryptfs/misc-ecryptfs-fixes-dec-2015
Merge into: lp:ecryptfs
Diff against target: 24 lines (+5/-2)
1 file modified
src/daemon/main.c (+5/-2)
To merge this branch: bzr merge lp:~colin-king/ecryptfs/misc-ecryptfs-fixes-dec-2015
Reviewer Review Type Date Requested Status
eCryptfs Pending
Review via email: mp+280764@code.launchpad.net

Description of the change

Static analysis with Clang's scan-build shows that we can potentially overflow the input buffer if the input is equal or more than the buffer size. Need to guard against this by:

1. Only reading in input_size - 1 chars
2. Checking earlier on to see if input_size is value to insure that we read in at least 1 char

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/daemon/main.c'
2--- src/daemon/main.c 2013-10-25 19:45:09 +0000
3+++ src/daemon/main.c 2015-12-16 19:36:41 +0000
4@@ -56,7 +56,10 @@
5 memset (input, 0, input_size);
6 }
7
8- if (prompt_prog == NULL) {
9+ /*
10+ * Make sure enough buffer size for at least 1 char and EOS
11+ */
12+ if ((input_size < 2) || (prompt_prog == NULL)) {
13 rc = -EINVAL;
14 goto out;
15 }
16@@ -118,7 +121,7 @@
17 }
18
19 if (!strcmp (prompt_type, "password")) {
20- if ((r = read (fds[0], input, input_size)) == -1) {
21+ if ((r = read (fds[0], input, input_size - 1)) == -1) {
22 rc = -errno;
23 goto out;
24 }

Subscribers

People subscribed via source and target branches