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)

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Freedos-kernel mailing list
Freedos-kernel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-kernel

Reply via email to