]> git.baikalelectronics.ru Git - kernel.git/commit
staging: comedi: avoid bad truncation of a size_t in comedi_write()
authorIan Abbott <abbotti@mev.co.uk>
Wed, 18 Nov 2015 17:55:07 +0000 (17:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Dec 2015 23:58:54 +0000 (15:58 -0800)
commit0112f40003ac5561628fc729b70ec579a2633c6a
tree13612d7e3c14fec4185ed0bc0b829bf3bef83b79
parenta5e607fa4696256858bfdeb66e5001e3e41689d3
staging: comedi: avoid bad truncation of a size_t in comedi_write()

At one point in `comedi_write()`, the variable `n` gets assigned to the
minimum of the parameter `nbytes` and the amount of writeable buffer
space.  The way that is done currently is unsafe in the unlikely case
that `nbytes` exceeds `UINT_MAX`, so fix it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c