Skip to content

Commit

Permalink
ncpfs: don't allow negative timeouts
Browse files Browse the repository at this point in the history
This code causes a static checker warning because it's a user controlled
variable where we cap the upper bound but not the lower bound.  Let's
return an -EINVAL for negative timeouts.

[[email protected]: remove unneeded `else']
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Cc: Petr Vandrovec <[email protected]>
Cc: David Howells <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dan Carpenter authored and torvalds committed Nov 21, 2015
1 parent 5cf6a51 commit 1491e30
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/ncpfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
switch (rqdata.cmd) {
case NCP_LOCK_EX:
case NCP_LOCK_SH:
if (rqdata.timeout < 0)
return -EINVAL;
if (rqdata.timeout == 0)
rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT;
else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT)
Expand Down

0 comments on commit 1491e30

Please sign in to comment.