lkml.org 
[lkml]   [2015]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] ncpfs: don't allow negative timeouts
On Tue 10-11-15 12:09:24, Dan Carpenter wrote:
> 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. If
> someone passes us a negative timeout then I guess lets set it to the
> default.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

IMHO it would be better to return error from the ioctl. Currently it would
just wrap when converting to u16 anyway...

Honza
>
> diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
> index 79b1130..c07498a 100644
> --- a/fs/ncpfs/ioctl.c
> +++ b/fs/ncpfs/ioctl.c
> @@ -525,7 +525,7 @@ 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)
> + if (rqdata.timeout <= 0)
> rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT;
> else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT)
> rqdata.timeout = NCP_LOCK_MAX_TIMEOUT;
--
Jan Kara <jack@suse.com>
SUSE Labs, CR


\
 
 \ /
  Last update: 2015-11-10 10:41    [W:0.069 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site