Fix infoleak to userspace.
authorIan Abbott <abbotti@mev.co.uk>
Mon, 27 Jun 2011 10:05:39 +0000 (11:05 +0100)
committerIan Abbott <abbotti@mev.co.uk>
Mon, 27 Jun 2011 10:05:39 +0000 (11:05 +0100)
Following Vasiliy Kulikov <segoon _at_ openwall _dot_ org>'s patch for
the staging sources:

driver_name and board_name are pointers to strings, not buffers of size
COMEDI_NAMELEN.  Copying COMEDI_NAMELEN bytes of a string containing
less than COMEDI_NAMELEN-1 bytes would leak some unrelated bytes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
comedi/comedi_fops.c

index b07a34bbd0bf08b878c07acdc6413806f2912c51..29fbcb34842e32c95fe5d14ce31bb1915a53b0f8 100644 (file)
@@ -397,8 +397,8 @@ static int do_devinfo_ioctl(comedi_device * dev, comedi_devinfo * arg,
        /* fill devinfo structure */
        devinfo.version_code = COMEDI_VERSION_CODE;
        devinfo.n_subdevs = dev->n_subdevices;
-       memcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
-       memcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
+       strlcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
+       strlcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
 
        if (read_subdev) {
                devinfo.read_subdevice = read_subdev - dev->subdevices;