Damien Guibouret
2015-04-26 19:35:23 UTC
Hello,
I found a small problem in ioctl code that leads to drive number 32 to not be
usable with device related functions (int 0x21, ah=0x44..) and leading to
returning information about another drive without signaling any error. As I
suppose this is not widely used (drive 27 to 32 are most often not known by
users), I think this is quite minor. I wrote a patch, but did not test nor even
compile it. In this patch I keep some code that from interface point of view is
wrong but that is the way I understood the "NDN" related comment.
Regards,
Damien
--- ioctl.c.orig 2015-04-26 21:01:18.000000000 +0200
+++ ioctl.c 2015-04-26 21:26:48.000000000 +0200
@@ -164,6 +164,7 @@
{
struct dpb FAR *dpbp;
unsigned attr;
+ BYTE used_drive;
/*
This line previously returned the deviceheader at r->bl. But,
DOS numbers its drives starting at 1, not 0. A=1, B=2, and so
@@ -173,9 +174,18 @@
*/
/* JPP - changed to use default drive if drive=0 */
/* JT Fixed it */
-
- /* NDN feeds the actual ASCII drive letter to this function */
- dpbp = get_dpb((r->BL & 0x1f) == 0 ? default_drive : (r->BL & 0x1f) - 1);
+ if (r->BL == 0)
+ used_drive = default_drive;
+ else if ((r->BL >= 1) && (r->BL <= 32))
+ used_drive = r->BL - 1;
+ else if (((r->BL >= 'A') && (r->BL <= 'Z')) ||
+ ((r->BL >= 'a') && (r->BL <= 'z')))
+ /* NDN feeds the actual ASCII drive letter to this function */
+ used_drive = (r->BL & 0x1f) - 1;
+ else
+ return DE_INVLDDRV;
+
+ dpbp = get_dpb(used_drive);
if (dpbp)
{
CharReqHdr.r_unit = dpbp->dpb_subunit;
@@ -196,7 +206,7 @@
{
/* note from get_dpb() */
/* that if cdsp == NULL then dev must be NULL too */
- struct cds FAR *cdsp = get_cds1(r->BL & 0x1f);
+ struct cds FAR *cdsp = get_cds(used_drive);
if (cdsp == NULL)
return DE_INVLDDRV;
if (cdsp->cdsFlags & CDSSUBST)
I found a small problem in ioctl code that leads to drive number 32 to not be
usable with device related functions (int 0x21, ah=0x44..) and leading to
returning information about another drive without signaling any error. As I
suppose this is not widely used (drive 27 to 32 are most often not known by
users), I think this is quite minor. I wrote a patch, but did not test nor even
compile it. In this patch I keep some code that from interface point of view is
wrong but that is the way I understood the "NDN" related comment.
Regards,
Damien
--- ioctl.c.orig 2015-04-26 21:01:18.000000000 +0200
+++ ioctl.c 2015-04-26 21:26:48.000000000 +0200
@@ -164,6 +164,7 @@
{
struct dpb FAR *dpbp;
unsigned attr;
+ BYTE used_drive;
/*
This line previously returned the deviceheader at r->bl. But,
DOS numbers its drives starting at 1, not 0. A=1, B=2, and so
@@ -173,9 +174,18 @@
*/
/* JPP - changed to use default drive if drive=0 */
/* JT Fixed it */
-
- /* NDN feeds the actual ASCII drive letter to this function */
- dpbp = get_dpb((r->BL & 0x1f) == 0 ? default_drive : (r->BL & 0x1f) - 1);
+ if (r->BL == 0)
+ used_drive = default_drive;
+ else if ((r->BL >= 1) && (r->BL <= 32))
+ used_drive = r->BL - 1;
+ else if (((r->BL >= 'A') && (r->BL <= 'Z')) ||
+ ((r->BL >= 'a') && (r->BL <= 'z')))
+ /* NDN feeds the actual ASCII drive letter to this function */
+ used_drive = (r->BL & 0x1f) - 1;
+ else
+ return DE_INVLDDRV;
+
+ dpbp = get_dpb(used_drive);
if (dpbp)
{
CharReqHdr.r_unit = dpbp->dpb_subunit;
@@ -196,7 +206,7 @@
{
/* note from get_dpb() */
/* that if cdsp == NULL then dev must be NULL too */
- struct cds FAR *cdsp = get_cds1(r->BL & 0x1f);
+ struct cds FAR *cdsp = get_cds(used_drive);
if (cdsp == NULL)
return DE_INVLDDRV;
if (cdsp->cdsFlags & CDSSUBST)