Gregor Schneider <grschneider@gmail.com>

- Return error code "buffer overflow" instead of "buffer too small" and only do that if really necessary
- Only append 0 if Length parameter allows to do so
- Use uppercase letters

Aleksey Bragin <aleksey@reactos.org>
- Wrap it into PSEH, however commented out till a solution for the bootloader is found (linking freeldr with PSEH is not very beautiful).
See issue #3583 for more details.

svn path=/trunk/; revision=34995
This commit is contained in:
Aleksey Bragin 2008-08-01 11:54:27 +00:00
parent 0e213bbc00
commit 6e81d0c92b

View file

@ -1515,6 +1515,7 @@ RtlLargeIntegerToChar(
IN ULONG Length, IN ULONG Length,
IN OUT PCHAR String) IN OUT PCHAR String)
{ {
NTSTATUS Status = STATUS_SUCCESS;
ULONG Radix; ULONG Radix;
CHAR temp[65]; CHAR temp[65];
ULONGLONG v = Value->QuadPart; ULONGLONG v = Value->QuadPart;
@ -1538,19 +1539,32 @@ RtlLargeIntegerToChar(
if (i < 10) if (i < 10)
*tp = i + '0'; *tp = i + '0';
else else
*tp = i + 'a' - 10; *tp = i + 'A' - 10;
tp++; tp++;
} }
if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) >= Length) if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) > Length)
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_OVERFLOW;
sp = String; //_SEH_TRY
while (tp > temp) {
*sp++ = *--tp; sp = String;
*sp = 0; while (tp > temp)
*sp++ = *--tp;
return STATUS_SUCCESS; if((ULONG)((ULONG_PTR)sp - (ULONG_PTR)String) < Length)
*sp = 0;
}
#if 0
_SEH_HANDLE
{
/* Get the error code */
Status = _SEH_GetExceptionCode();
}
_SEH_END;
#endif
return Status;
} }
/* /*