diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d6f56576d..35bd30c33 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2005-12-07 Corinna Vinschen + + * fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix setting devbuf + when rd_parm is 0 or 1. + 2005-12-07 Corinna Vinschen * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Fix test for diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 479515fe5..3f45703c9 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -161,7 +161,9 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf) ret = ERROR_INVALID_PARAMETER; else if (!devbuf || op->rd_parm != devbufsiz) { - char *buf = new char [op->rd_parm]; + char *buf = NULL; + if (op->rd_parm > 1L) + buf = new char [op->rd_parm]; if (devbufsiz > 1L) { memcpy (buf, devbuf + devbufstart, devbufend - devbufstart); @@ -173,7 +175,7 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf) devbufstart = 0; devbuf = buf; - devbufsiz = op->rd_parm; + devbufsiz = op->rd_parm ?: 1L; } break; default: @@ -187,7 +189,7 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf) if (!get) ret = ERROR_INVALID_PARAMETER; else - get->bufsiz = devbufsiz ? devbufsiz : 1L; + get->bufsiz = devbufsiz ?: 1L; } else return fhandler_base::ioctl (cmd, buf);