Pass volume label a unterminated Unicode string.

svn path=/trunk/; revision=6631
This commit is contained in:
Eric Kohl 2003-11-12 21:02:42 +00:00
parent 2b33d147c1
commit 4ceed6aba6

View file

@ -1,6 +1,6 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002 ReactOS Team * Copyright (C) 2002, 2003 ReactOS Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,13 +16,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: volinfo.c,v 1.3 2002/05/07 22:42:46 hbirr Exp $ /* $Id: volinfo.c,v 1.4 2003/11/12 21:02:42 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/vfat/volume.c * FILE: services/fs/vfat/volume.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -42,29 +43,28 @@ CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject,
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo, PFILE_FS_VOLUME_INFORMATION FsVolumeInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
ULONG LabelLength;
DPRINT("CdfsGetFsVolumeInformation() called\n"); DPRINT("CdfsGetFsVolumeInformation() called\n");
DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo); DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
DPRINT("Vpb %p\n", DeviceObject->Vpb); DPRINT("Vpb %p\n", DeviceObject->Vpb);
LabelLength = DeviceObject->Vpb->VolumeLabelLength;
DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + LabelLength*sizeof(WCHAR))); DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength));
DPRINT("LabelLength %lu\n", LabelLength); DPRINT("LabelLength %hu\n", DeviceObject->Vpb->VolumeLabelLength);
DPRINT("Label %S\n", DeviceObject->Vpb->VolumeLabel); DPRINT("Label %*.S\n", DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR), DeviceObject->Vpb->VolumeLabel);
if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION)) if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION))
return STATUS_INFO_LENGTH_MISMATCH; return STATUS_INFO_LENGTH_MISMATCH;
if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + LabelLength*sizeof(WCHAR))) if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
/* valid entries */ /* valid entries */
FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber; FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
FsVolumeInfo->VolumeLabelLength = LabelLength * sizeof (WCHAR); FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
wcscpy(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel); memcpy(FsVolumeInfo->VolumeLabel,
DeviceObject->Vpb->VolumeLabel,
DeviceObject->Vpb->VolumeLabelLength);
/* dummy entries */ /* dummy entries */
FsVolumeInfo->VolumeCreationTime.QuadPart = 0; FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
@ -72,7 +72,7 @@ CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject,
DPRINT("Finished FsdGetFsVolumeInformation()\n"); DPRINT("Finished FsdGetFsVolumeInformation()\n");
*BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + LabelLength * sizeof(WCHAR)); *BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
@ -165,7 +165,6 @@ CdfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
} }
NTSTATUS STDCALL NTSTATUS STDCALL
CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)