mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTOS:KD] Protect against invalid user arguments in KdpPrintString. CORE-14057
This commit is contained in:
parent
1a38c76266
commit
34ccecbce8
2 changed files with 28 additions and 4 deletions
|
@ -193,8 +193,8 @@ KdpCallGdb(
|
|||
ULONG
|
||||
NTAPI
|
||||
KdpPrintString(
|
||||
LPSTR String,
|
||||
ULONG Length);
|
||||
_In_reads_bytes_(Length) PCHAR UnsafeString,
|
||||
_In_ ULONG Length);
|
||||
|
||||
ULONG
|
||||
NTAPI
|
||||
|
|
|
@ -567,14 +567,38 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
|
|||
|
||||
ULONG
|
||||
NTAPI
|
||||
KdpPrintString(LPSTR String,
|
||||
ULONG Length)
|
||||
KdpPrintString(
|
||||
_In_reads_bytes_(Length) PCHAR UnsafeString,
|
||||
_In_ ULONG Length)
|
||||
{
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PKD_DISPATCH_TABLE CurrentTable;
|
||||
PCHAR String;
|
||||
|
||||
if (!KdpDebugMode.Value) return 0;
|
||||
|
||||
Length = min(Length, 512);
|
||||
|
||||
if (ExGetPreviousMode() != KernelMode)
|
||||
{
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForRead(UnsafeString, Length, 1);
|
||||
String = _alloca(Length + 1);
|
||||
RtlCopyMemory(String, UnsafeString, Length);
|
||||
String[Length] = ANSI_NULL;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
_SEH2_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
String = UnsafeString;
|
||||
}
|
||||
|
||||
/* Call the registered handlers */
|
||||
CurrentEntry = KdProviders.Flink;
|
||||
while (CurrentEntry != &KdProviders)
|
||||
|
|
Loading…
Reference in a new issue