From 6e81d0c92b38946b6f75e94b84bce8de0f9f19f5 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 1 Aug 2008 11:54:27 +0000 Subject: [PATCH] Gregor Schneider - 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 - 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 --- reactos/lib/rtl/unicode.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/reactos/lib/rtl/unicode.c b/reactos/lib/rtl/unicode.c index eb2f28debb8..4b86aa6a9fd 100644 --- a/reactos/lib/rtl/unicode.c +++ b/reactos/lib/rtl/unicode.c @@ -1515,6 +1515,7 @@ RtlLargeIntegerToChar( IN ULONG Length, IN OUT PCHAR String) { + NTSTATUS Status = STATUS_SUCCESS; ULONG Radix; CHAR temp[65]; ULONGLONG v = Value->QuadPart; @@ -1538,19 +1539,32 @@ RtlLargeIntegerToChar( if (i < 10) *tp = i + '0'; else - *tp = i + 'a' - 10; + *tp = i + 'A' - 10; tp++; } - if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) >= Length) - return STATUS_BUFFER_TOO_SMALL; + if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) > Length) + return STATUS_BUFFER_OVERFLOW; - sp = String; - while (tp > temp) - *sp++ = *--tp; - *sp = 0; + //_SEH_TRY + { + sp = String; + 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; } /*