mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 08:52:57 +00:00
- Thomas Weidenmueller (w3seek@reactos.org)
- Use SEH in Atom functions - Only use result length if the caller gave one, in NtQuerySecurityObject. svn path=/trunk/; revision=22001
This commit is contained in:
parent
8a80070849
commit
ee3fddd2d7
2 changed files with 99 additions and 61 deletions
|
@ -284,13 +284,31 @@ NtQueryInformationAtom(RTL_ATOM Atom,
|
||||||
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
|
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
|
||||||
PATOM_BASIC_INFORMATION BasicInformation = AtomInformation;
|
PATOM_BASIC_INFORMATION BasicInformation = AtomInformation;
|
||||||
PATOM_TABLE_INFORMATION TableInformation = AtomInformation;
|
PATOM_TABLE_INFORMATION TableInformation = AtomInformation;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
ULONG Flags, UsageCount, NameLength;
|
ULONG Flags, UsageCount, NameLength, RequiredLength = 0;
|
||||||
|
KPROCESSOR_MODE PreviousMode;
|
||||||
|
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Check for valid table */
|
/* Check for valid table */
|
||||||
if (AtomTable == NULL) return STATUS_ACCESS_DENIED;
|
if (AtomTable == NULL) return STATUS_ACCESS_DENIED;
|
||||||
|
|
||||||
/* FIXME: SEH! */
|
PreviousMode = ExGetPreviousMode();
|
||||||
|
|
||||||
|
_SEH_TRY
|
||||||
|
{
|
||||||
|
/* Probe the parameters */
|
||||||
|
if (PreviousMode != KernelMode)
|
||||||
|
{
|
||||||
|
ProbeForWrite(AtomInformation,
|
||||||
|
AtomInformationLength,
|
||||||
|
sizeof(ULONG));
|
||||||
|
|
||||||
|
if (ReturnLength != NULL)
|
||||||
|
{
|
||||||
|
ProbeForWriteUlong(ReturnLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Choose class */
|
/* Choose class */
|
||||||
switch (AtomInformationClass)
|
switch (AtomInformationClass)
|
||||||
|
@ -299,17 +317,18 @@ NtQueryInformationAtom(RTL_ATOM Atom,
|
||||||
case AtomBasicInformation:
|
case AtomBasicInformation:
|
||||||
|
|
||||||
/* Size check */
|
/* Size check */
|
||||||
*ReturnLength = FIELD_OFFSET(ATOM_BASIC_INFORMATION, Name);
|
RequiredLength = FIELD_OFFSET(ATOM_BASIC_INFORMATION, Name);
|
||||||
if (*ReturnLength > AtomInformationLength)
|
if (RequiredLength > AtomInformationLength)
|
||||||
{
|
{
|
||||||
/* Fail */
|
/* Fail */
|
||||||
DPRINT1("Buffer too small\n");
|
DPRINT1("Buffer too small\n");
|
||||||
return STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare query */
|
/* Prepare query */
|
||||||
UsageCount = 0;
|
UsageCount = 0;
|
||||||
NameLength = AtomInformationLength - *ReturnLength;
|
NameLength = AtomInformationLength - RequiredLength;
|
||||||
BasicInformation->Name[0] = UNICODE_NULL;
|
BasicInformation->Name[0] = UNICODE_NULL;
|
||||||
|
|
||||||
/* Query the data */
|
/* Query the data */
|
||||||
|
@ -325,7 +344,7 @@ NtQueryInformationAtom(RTL_ATOM Atom,
|
||||||
BasicInformation->UsageCount = (USHORT)UsageCount;
|
BasicInformation->UsageCount = (USHORT)UsageCount;
|
||||||
BasicInformation->Flags = (USHORT)Flags;
|
BasicInformation->Flags = (USHORT)Flags;
|
||||||
BasicInformation->NameLength = (USHORT)NameLength;
|
BasicInformation->NameLength = (USHORT)NameLength;
|
||||||
*ReturnLength += NameLength + sizeof(WCHAR);
|
RequiredLength += NameLength + sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -333,25 +352,25 @@ NtQueryInformationAtom(RTL_ATOM Atom,
|
||||||
case AtomTableInformation:
|
case AtomTableInformation:
|
||||||
|
|
||||||
/* Size check */
|
/* Size check */
|
||||||
*ReturnLength = FIELD_OFFSET(ATOM_TABLE_INFORMATION, Atoms);
|
RequiredLength = FIELD_OFFSET(ATOM_TABLE_INFORMATION, Atoms);
|
||||||
if (*ReturnLength > AtomInformationLength)
|
if (RequiredLength > AtomInformationLength)
|
||||||
{
|
{
|
||||||
/* Fail */
|
/* Fail */
|
||||||
DPRINT1("Buffer too small\n");
|
DPRINT1("Buffer too small\n");
|
||||||
return STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
|
_SEH_LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Query the data */
|
/* Query the data */
|
||||||
Status = RtlQueryAtomListInAtomTable(AtomTable,
|
Status = RtlQueryAtomListInAtomTable(AtomTable,
|
||||||
(AtomInformationLength - *ReturnLength) /
|
(AtomInformationLength - RequiredLength) /
|
||||||
sizeof(RTL_ATOM),
|
sizeof(RTL_ATOM),
|
||||||
&TableInformation->NumberOfAtoms,
|
&TableInformation->NumberOfAtoms,
|
||||||
TableInformation->Atoms);
|
TableInformation->Atoms);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Update the return length */
|
/* Update the return length */
|
||||||
*ReturnLength += TableInformation->NumberOfAtoms *
|
RequiredLength += TableInformation->NumberOfAtoms * sizeof(RTL_ATOM);
|
||||||
sizeof(RTL_ATOM);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -360,8 +379,21 @@ NtQueryInformationAtom(RTL_ATOM Atom,
|
||||||
|
|
||||||
/* Unrecognized class */
|
/* Unrecognized class */
|
||||||
Status = STATUS_INVALID_INFO_CLASS;
|
Status = STATUS_INVALID_INFO_CLASS;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the required size */
|
||||||
|
if (ReturnLength != NULL)
|
||||||
|
{
|
||||||
|
*ReturnLength = RequiredLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
|
||||||
|
{
|
||||||
|
Status = _SEH_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH_END;
|
||||||
|
|
||||||
/* Return to caller */
|
/* Return to caller */
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,8 +240,11 @@ NtQuerySecurityObject(IN HANDLE Handle,
|
||||||
_SEH_TRY
|
_SEH_TRY
|
||||||
{
|
{
|
||||||
ProbeForWrite(SecurityDescriptor, Length, sizeof(ULONG));
|
ProbeForWrite(SecurityDescriptor, Length, sizeof(ULONG));
|
||||||
|
if (ResultLength != NULL)
|
||||||
|
{
|
||||||
ProbeForWriteUlong(ResultLength);
|
ProbeForWriteUlong(ResultLength);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_SEH_HANDLE
|
_SEH_HANDLE
|
||||||
{
|
{
|
||||||
Status = _SEH_GetExceptionCode();
|
Status = _SEH_GetExceptionCode();
|
||||||
|
@ -280,16 +283,19 @@ NtQuerySecurityObject(IN HANDLE Handle,
|
||||||
ObDereferenceObject(Object);
|
ObDereferenceObject(Object);
|
||||||
|
|
||||||
/* return the required length */
|
/* return the required length */
|
||||||
|
if (ResultLength != NULL)
|
||||||
|
{
|
||||||
_SEH_TRY
|
_SEH_TRY
|
||||||
{
|
{
|
||||||
*ResultLength = Length;
|
*ResultLength = Length;
|
||||||
}
|
}
|
||||||
_SEH_HANDLE
|
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
|
||||||
{
|
{
|
||||||
Status = _SEH_GetExceptionCode();
|
Status = _SEH_GetExceptionCode();
|
||||||
}
|
}
|
||||||
_SEH_END;
|
_SEH_END;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue