mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[NTOSKRNL]
Change strncpy calls to RtlStringSbCopyA (PART 1/x) Fix bug in MmLoadSystemImage which caused FileName parameter to be freed svn path=/trunk/; revision=51138
This commit is contained in:
parent
54dc46543f
commit
547a7d215f
3 changed files with 18 additions and 18 deletions
|
@ -2490,14 +2490,12 @@ KdbpReadCommand(
|
||||||
*/
|
*/
|
||||||
if (Buffer == Orig)
|
if (Buffer == Orig)
|
||||||
{
|
{
|
||||||
strncpy(Buffer, LastCommand, Size);
|
RtlStringCbCopyA(Buffer, Size, LastCommand);
|
||||||
Buffer[Size - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*Buffer = '\0';
|
*Buffer = '\0';
|
||||||
strncpy(LastCommand, Orig, sizeof (LastCommand));
|
RtlStringCbCopyA(LastCommand, sizeof(LastCommand), Orig);
|
||||||
LastCommand[sizeof (LastCommand) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -2614,8 +2612,7 @@ KdbpDoCommand(
|
||||||
static PCH Argv[256];
|
static PCH Argv[256];
|
||||||
static CHAR OrigCommand[1024];
|
static CHAR OrigCommand[1024];
|
||||||
|
|
||||||
strncpy(OrigCommand, Command, sizeof(OrigCommand) - 1);
|
RtlStringCbCopyA(OrigCommand, sizeof(OrigCommand), Command);
|
||||||
OrigCommand[sizeof(OrigCommand) - 1] = '\0';
|
|
||||||
|
|
||||||
Argc = 0;
|
Argc = 0;
|
||||||
p = Command;
|
p = Command;
|
||||||
|
|
|
@ -947,6 +947,8 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
||||||
WCHAR PathSetup[] = L"\\SystemRoot\\";
|
WCHAR PathSetup[] = L"\\SystemRoot\\";
|
||||||
CHAR DriverNameLow[256];
|
CHAR DriverNameLow[256];
|
||||||
ULONG Base;
|
ULONG Base;
|
||||||
|
size_t Remaining;
|
||||||
|
WCHAR *StringEnd;
|
||||||
#if defined(_PPC_)
|
#if defined(_PPC_)
|
||||||
ULONG KernelBase = RosLoaderBlock->ModsAddr[0].ModStart;
|
ULONG KernelBase = RosLoaderBlock->ModsAddr[0].ModStart;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1123,7 +1125,7 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
||||||
|
|
||||||
/* Construct a correct full name */
|
/* Construct a correct full name */
|
||||||
BldrModuleStringsFull[i][0] = 0;
|
BldrModuleStringsFull[i][0] = 0;
|
||||||
LdrEntry->FullDllName.MaximumLength = 260 * sizeof(WCHAR);
|
LdrEntry->FullDllName.MaximumLength = sizeof(BldrModuleStringsFull[i]);
|
||||||
LdrEntry->FullDllName.Length = 0;
|
LdrEntry->FullDllName.Length = 0;
|
||||||
LdrEntry->FullDllName.Buffer = BldrModuleStringsFull[i];
|
LdrEntry->FullDllName.Buffer = BldrModuleStringsFull[i];
|
||||||
|
|
||||||
|
@ -1256,25 +1258,26 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
||||||
/* Find the first \, separating the ARC path from NT path */
|
/* Find the first \, separating the ARC path from NT path */
|
||||||
BootPath = strchr(CommandLine, '\\');
|
BootPath = strchr(CommandLine, '\\');
|
||||||
*BootPath = ANSI_NULL;
|
*BootPath = ANSI_NULL;
|
||||||
strncpy(BldrArcBootPath, CommandLine, 63);
|
RtlStringCbCopyA(BldrArcBootPath, sizeof(BldrArcBootPath), CommandLine);
|
||||||
LoaderBlock->ArcBootDeviceName = BldrArcBootPath;
|
LoaderBlock->ArcBootDeviceName = BldrArcBootPath;
|
||||||
|
|
||||||
/* The rest of the string is the NT path */
|
/* The rest of the string is the NT path */
|
||||||
HalPath = strchr(BootPath + 1, ' ');
|
HalPath = strchr(BootPath + 1, ' ');
|
||||||
*HalPath = ANSI_NULL;
|
*HalPath = ANSI_NULL;
|
||||||
BldrNtBootPath[0] = '\\';
|
Remaining = sizeof(BldrNtBootPath);
|
||||||
strncat(BldrNtBootPath, BootPath + 1, 61);
|
RtlStringCbCopyExA(BldrNtBootPath, Remaining, "\\", &StringEnd, &Remaining, 0);
|
||||||
strcat(BldrNtBootPath,"\\");
|
RtlStringCbCopyExA(StringEnd, Remaining, BootPath + 1, &StringEnd, &Remaining, 0);
|
||||||
|
RtlStringCbCopyA(StringEnd, Remaining, "\\");
|
||||||
LoaderBlock->NtBootPathName = BldrNtBootPath;
|
LoaderBlock->NtBootPathName = BldrNtBootPath;
|
||||||
|
|
||||||
/* Set the HAL paths */
|
/* Set the HAL paths */
|
||||||
strncpy(BldrArcHalPath, BldrArcBootPath, 63);
|
RtlStringCbCopyA(BldrArcHalPath, sizeof(BldrArcHalPath), BldrArcBootPath);
|
||||||
LoaderBlock->ArcHalDeviceName = BldrArcHalPath;
|
LoaderBlock->ArcHalDeviceName = BldrArcHalPath;
|
||||||
strcpy(BldrNtHalPath, "\\");
|
strcpy(BldrNtHalPath, "\\");
|
||||||
LoaderBlock->NtHalPathName = BldrNtHalPath;
|
LoaderBlock->NtHalPathName = BldrNtHalPath;
|
||||||
|
|
||||||
/* Use this new command line */
|
/* Use this new command line */
|
||||||
strncpy(LoaderBlock->LoadOptions, HalPath + 2, 255);
|
RtlStringCbCopyA(LoaderBlock->LoadOptions, 255, HalPath + 2);
|
||||||
|
|
||||||
/* Parse it and change every slash to a space */
|
/* Parse it and change every slash to a space */
|
||||||
BootPath = LoaderBlock->LoadOptions;
|
BootPath = LoaderBlock->LoadOptions;
|
||||||
|
|
|
@ -710,9 +710,9 @@ MiSnapThunk(IN PVOID DllBase,
|
||||||
NameImport = (PIMAGE_IMPORT_BY_NAME)Name->u1.AddressOfData;
|
NameImport = (PIMAGE_IMPORT_BY_NAME)Name->u1.AddressOfData;
|
||||||
|
|
||||||
/* Copy the procedure name */
|
/* Copy the procedure name */
|
||||||
strncpy(*MissingApi,
|
RtlStringCbCopyA(*MissingApi,
|
||||||
(PCHAR)&NameImport->Name[0],
|
MAXIMUM_FILENAME_LENGTH,
|
||||||
MAXIMUM_FILENAME_LENGTH - 1);
|
(PCHAR)&NameImport->Name[0]);
|
||||||
|
|
||||||
/* Setup name tables */
|
/* Setup name tables */
|
||||||
DPRINT("Import name: %s\n", NameImport->Name);
|
DPRINT("Import name: %s\n", NameImport->Name);
|
||||||
|
@ -3000,8 +3000,8 @@ Quickie:
|
||||||
/* If we have a file handle, close it */
|
/* If we have a file handle, close it */
|
||||||
if (FileHandle) ZwClose(FileHandle);
|
if (FileHandle) ZwClose(FileHandle);
|
||||||
|
|
||||||
/* Check if we had a prefix */
|
/* Check if we had a prefix (not supported yet - PrefixName == *FileName now) */
|
||||||
if (NamePrefix) ExFreePool(PrefixName.Buffer);
|
/* if (NamePrefix) ExFreePool(PrefixName.Buffer); */
|
||||||
|
|
||||||
/* Free the name buffer and return status */
|
/* Free the name buffer and return status */
|
||||||
ExFreePoolWithTag(Buffer, TAG_LDR_WSTR);
|
ExFreePoolWithTag(Buffer, TAG_LDR_WSTR);
|
||||||
|
|
Loading…
Reference in a new issue