Author: fireball
Date: Fri Aug 1 06:54:27 2008
New Revision: 34995
URL:
http://svn.reactos.org/svn/reactos?rev=34995&view=rev
Log:
Gregor Schneider <grschneider(a)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(a)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.
Modified:
trunk/reactos/lib/rtl/unicode.c
Modified: trunk/reactos/lib/rtl/unicode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/unicode.c?rev=3499…
==============================================================================
--- trunk/reactos/lib/rtl/unicode.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/unicode.c [iso-8859-1] Fri Aug 1 06:54:27 2008
@@ -1515,6 +1515,7 @@
IN ULONG Length,
IN OUT PCHAR String)
{
+ NTSTATUS Status = STATUS_SUCCESS;
ULONG Radix;
CHAR temp[65];
ULONGLONG v = Value->QuadPart;
@@ -1538,19 +1539,32 @@
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;
-
- sp = String;
- while (tp > temp)
- *sp++ = *--tp;
- *sp = 0;
-
- return STATUS_SUCCESS;
+ if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) > Length)
+ return STATUS_BUFFER_OVERFLOW;
+
+ //_SEH_TRY
+ {
+ sp = String;
+ while (tp > temp)
+ *sp++ = *--tp;
+
+ 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;
}
/*