* fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix INVALID_PARAMETER
condition. Only copy devbuf to buf if buf is non-NULL.
This commit is contained in:
parent
bb4e8382c5
commit
db58e35d94
@ -1,3 +1,8 @@
|
|||||||
|
2005-12-07 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix INVALID_PARAMETER
|
||||||
|
condition. Only copy devbuf to buf if buf is non-NULL.
|
||||||
|
|
||||||
2005-12-07 Corinna Vinschen <corinna@vinschen.de>
|
2005-12-07 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix setting devbuf
|
* fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix setting devbuf
|
||||||
|
@ -157,22 +157,25 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf)
|
|||||||
mop.mt_count = op->rd_parm;
|
mop.mt_count = op->rd_parm;
|
||||||
ret = ioctl (MTIOCTOP, &mop);
|
ret = ioctl (MTIOCTOP, &mop);
|
||||||
}
|
}
|
||||||
else if (devbuf && op->rd_parm < devbufend - devbufstart)
|
else if (devbuf && ((op->rd_parm <= 1 && (devbufend - devbufstart))
|
||||||
|
|| op->rd_parm < devbufend - devbufstart))
|
||||||
ret = ERROR_INVALID_PARAMETER;
|
ret = ERROR_INVALID_PARAMETER;
|
||||||
else if (!devbuf || op->rd_parm != devbufsiz)
|
else if (!devbuf || op->rd_parm != devbufsiz)
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
if (op->rd_parm > 1L)
|
if (op->rd_parm > 1L)
|
||||||
buf = new char [op->rd_parm];
|
buf = new char [op->rd_parm];
|
||||||
if (devbufsiz > 1L)
|
if (buf && devbufsiz > 1L)
|
||||||
{
|
{
|
||||||
memcpy (buf, devbuf + devbufstart, devbufend - devbufstart);
|
memcpy (buf, devbuf + devbufstart, devbufend - devbufstart);
|
||||||
devbufend -= devbufstart;
|
devbufend -= devbufstart;
|
||||||
delete [] devbuf;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
devbufend = 0;
|
devbufend = 0;
|
||||||
|
|
||||||
|
if (devbufsiz > 1L)
|
||||||
|
delete [] devbuf;
|
||||||
|
|
||||||
devbufstart = 0;
|
devbufstart = 0;
|
||||||
devbuf = buf;
|
devbuf = buf;
|
||||||
devbufsiz = op->rd_parm ?: 1L;
|
devbufsiz = op->rd_parm ?: 1L;
|
||||||
|
Loading…
Reference in New Issue
Block a user