]> git.baikalelectronics.ru Git - kernel.git/commit
staging: comedi: avoid bad truncation of a size_t in comedi_read()
authorIan Abbott <abbotti@mev.co.uk>
Mon, 12 Oct 2015 16:21:24 +0000 (17:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Oct 2015 17:29:48 +0000 (10:29 -0700)
commite67567439b18a9615197da71f3aff47eb8819b1a
tree74f90531d32eb15b673d6882f9783aeae893b6dc
parent9a0a9fb2a66b3aaef362863bd0a7a948b82853db
staging: comedi: avoid bad truncation of a size_t in comedi_read()

At one point in `comedi_read()`, the variable `n` gets assigned to the
minimum of the parameter `nbytes` and the amount of readable buffer
space `m`.  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