Author: fireball
Date: Thu Aug 5 21:57:02 2010
New Revision: 48468
URL:
http://svn.reactos.org/svn/reactos?rev=48468&view=rev
Log:
[CDFS]
- 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.
Modified:
trunk/reactos/drivers/filesystems/cdfs/cdfs.h
trunk/reactos/drivers/filesystems/cdfs/fsctl.c
Modified: trunk/reactos/drivers/filesystems/cdfs/cdfs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] Thu Aug 5 21:57:02 2010
@@ -142,7 +142,7 @@
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;
Modified: trunk/reactos/drivers/filesystems/cdfs/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fsctl.c [iso-8859-1] Thu Aug 5 21:57:02 2010
@@ -73,11 +73,24 @@
/* 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;