[CDFS]
authorAleksey Bragin <aleksey@reactos.org>
Thu, 5 Aug 2010 21:57:02 +0000 (21:57 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Thu, 5 Aug 2010 21:57:02 +0000 (21:57 +0000)
- MAXIMUM_VOLUME_LABEL_LENGTH is in bytes, not in characters. Fix struct definition and access beyond the buffer. Spotted by Carlo Bramini.
- Trim trailing spaces from the volume label name, instead of stopping at the first encountered space. Fix by Carlo Bramini.
See issue #5505 for more details.

svn path=/trunk/; revision=48468

reactos/drivers/filesystems/cdfs/cdfs.h
reactos/drivers/filesystems/cdfs/fsctl.c

index 3f686d3..3b114ef 100644 (file)
@@ -142,7 +142,7 @@ typedef struct _CDINFO
   ULONG JolietLevel;
   ULONG RootStart;
   ULONG RootSize;
-  WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
+  WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
   ULONG VolumeLabelLength;
   ULONG SerialNumber;
 } CDINFO, *PCDINFO;
index 897c081..95db2ea 100644 (file)
@@ -73,11 +73,24 @@ CdfsGetPVDData(PUCHAR Buffer,
     /* Extract the volume label */
     pc = Pvd->VolumeId;
     pw = CdInfo->VolumeLabel;
-    for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH && *pc != ' '; i++)
+    for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR); i++)
     {
         *pw++ = (WCHAR)*pc++;
     }
     *pw = 0;
+
+    /* Trim trailing spaces */
+    while (pw > CdInfo->VolumeLabel)
+    {
+        if (*--pw != ' ') break;
+
+        /* Remove the space */
+        *pw = '\0';
+
+        /* Decrease size */
+        i--;
+    }
+
     CdInfo->VolumeLabelLength = i * sizeof(WCHAR);
 
     CdInfo->VolumeSpaceSize = Pvd->VolumeSpaceSizeL;