Fixed FAT short file name buffer overflow that was causing some long filenames not to work correctly.

svn path=/trunk/; revision=2892
This commit is contained in:
Brian Palmer 2002-04-28 20:31:42 +00:00
parent efa19d923d
commit a28d727f4e
7 changed files with 37 additions and 15 deletions

20
freeldr/CHANGELOG Normal file
View file

@ -0,0 +1,20 @@
Changes in v1.01 (4/28/2002)
- Fixed FAT short file name buffer overflow that was causing
some long filenames not to work correctly.
Changes in v1.0 (4/24/2002)
- FreeLoader version 1.0!
- Supports booting ReactOS
- Supports booting Linux bzImage kernels
- No initrd support (yet)
- No zImage support (yet)
- No ext2 file system support (yet)
- Supports FAT & ISO-9660 file systems
- Forward slashes '/' as well as backslashes '\' can be used
for path names in FAT & ISO-9600
- Fixed bug in LBA code where it was only reading one sector
even if you asked for more
- Fixed bug in FAT code, was also present in ISO-9660 code where
it wasn't incrementing the buffer address correctly

View file

@ -102,7 +102,6 @@ SelectedTextColor=Black
SelectedColor=Gray
; Load ReactOS from harddisk (drive C:)
; - does not work on large harddisks
[ReactOS (HD)]
Name="ReactOS (HardDrive)"
BootType=ReactOS
@ -136,10 +135,10 @@ Driver=\reactos\VFATFS.SYS
[Linux]
Name="Debian Linux 2.2.17"
BootType=Partition
BootType=Linux
BootDrive=0
Kernel=/vmlinuz
CommandLine=root=/dev/sdb1
CommandLine="root=/dev/sdb1"
[3« Floppy (A:)]
Name="3« Floppy (A:)"

View file

@ -27,8 +27,8 @@
//ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
// DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
// DPRINT_LINUX;
ULONG DebugPrintMask = DPRINT_WARNING | /*DPRINT_FILESYSTEM |
DPRINT_CACHE |*/ DPRINT_LINUX;
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_FILESYSTEM |
/*DPRINT_CACHE |*/ DPRINT_LINUX;
//ULONG DebugPrintMask = DPRINT_INIFILE;
#define SCREEN 0

View file

@ -22,11 +22,11 @@
/* just some stuff */
#define VERSION "FreeLoader v1.0"
#define VERSION "FreeLoader v1.01"
#define COPYRIGHT "Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>"
#define ROSLDR_MAJOR_VERSION 1
#define ROSLDR_MINOR_VERSION 0
#define ROSLDR_MINOR_VERSION 01
#define ROSLDR_PATCH_VERSION 0
#define size_t unsigned int

View file

@ -356,8 +356,8 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, UINT32 EntryCount, P
ULONG CurrentEntry;
PDIRENTRY DirEntry;
PLFN_DIRENTRY LfnDirEntry;
UCHAR LfnNameBuffer[261];
UCHAR ShortNameBuffer[13];
UCHAR LfnNameBuffer[265];
UCHAR ShortNameBuffer[20];
UINT32 StartCluster;
DbgPrint((DPRINT_FILESYSTEM, "FatSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x EntryCount = %d FileName = %s\n", DirectoryBuffer, EntryCount, FileName));
@ -370,6 +370,9 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, UINT32 EntryCount, P
DirEntry = (PDIRENTRY)(DirectoryBuffer + (CurrentEntry * 32) );
LfnDirEntry = (PLFN_DIRENTRY)DirEntry;
//DbgPrint((DPRINT_FILESYSTEM, "Dumping directory entry %d:\n", CurrentEntry));
//DbgDumpBuffer(DPRINT_FILESYSTEM, DirEntry, sizeof(DIRENTRY));
//
// Check if this is the last file in the directory
// If DirEntry[0] == 0x00 then that means all the
@ -468,6 +471,9 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, UINT32 EntryCount, P
LfnNameBuffer[12 + (LfnDirEntry->SequenceNumber * 13)] = (UCHAR)LfnDirEntry->Name11_12[1];
}
//DbgPrint((DPRINT_FILESYSTEM, "Dumping long name buffer:\n"));
//DbgDumpBuffer(DPRINT_FILESYSTEM, LfnNameBuffer, 260);
continue;
}
@ -707,6 +713,7 @@ void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
ULONG Idx;
Idx = 0;
RtlZeroMemory(Buffer, 13);
//
// Fixup first character
@ -741,11 +748,6 @@ void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
Buffer[Idx++] = (DirEntry->FileName[10] == ' ') ? '\0' : DirEntry->FileName[10];
}
//
// Null-Terminate string
//
Buffer[Idx + 4] = '\0';
DbgPrint((DPRINT_FILESYSTEM, "FatParseShortFileName() ShortName = %s\n", Buffer));
}

View file

@ -28,6 +28,7 @@
#include "debug.h"
#include "mm.h"
#include "inifile.h"
#include "oslist.h" // For RemoveQuotes()
PLINUX_BOOTSECTOR LinuxBootSector = NULL;
PLINUX_SETUPSECTOR LinuxSetupSector = NULL;
@ -176,6 +177,7 @@ BOOL LinuxParseIniSection(PUCHAR OperatingSystemName)
// Get the command line
if (IniReadSettingByName(SectionId, "CommandLine", LinuxCommandLine, 260))
{
RemoveQuotes(LinuxCommandLine);
LinuxCommandLineSize = strlen(LinuxCommandLine) + 1;
}

View file

@ -84,7 +84,6 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
// Read boot sector
if (!ReadFile(FilePointer, 512, &BytesRead, (void*)0x7c00) || (BytesRead != 512))
{
DiskError("Disk read error.");
return;
}