From 0766c089ece92af98b42e518f410e6d8e0e7011a Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Thu, 17 Jun 2004 03:47:39 +0000 Subject: [PATCH] This makes RtlUnicodeStringToInteger work like the win2k version. Basically this function never checks the validity of the input string and only returns an error when the Base argument is set incorrectly. This fixes the bug while booting vmware with the pcnet card on. svn path=/trunk/; revision=9694 --- reactos/lib/rtl/unicode.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/reactos/lib/rtl/unicode.c b/reactos/lib/rtl/unicode.c index 83ee674408c..be4fe577d53 100644 --- a/reactos/lib/rtl/unicode.c +++ b/reactos/lib/rtl/unicode.c @@ -673,6 +673,13 @@ RtlPrefixUnicodeString( /* * @implemented + * + * Note that regardless of success or failure status, we should leave the + * partial value in Value. An error is never returned based on the chars + * in the string. + * + * This function does check the base. Only 2, 8, 10, 16 are permitted, + * else STATUS_INVALID_PARAMETER is returned. */ NTSTATUS STDCALL @@ -686,10 +693,14 @@ RtlUnicodeStringToInteger( ULONG i; ULONG Val; BOOLEAN addneg = FALSE; + NTSTATUS Status = STATUS_SUCCESS; *Value = 0; Str = String->Buffer; + if( Base && Base != 2 && Base != 8 && Base != 10 && Base != 16 ) + return STATUS_INVALID_PARAMETER; + for (i = 0; i < String->Length / sizeof(WCHAR); i++) { if (*Str == L'b') @@ -723,21 +734,21 @@ RtlUnicodeStringToInteger( } else if ((*Str > L'1') && (Base == 2)) { - return STATUS_INVALID_PARAMETER; + break; } else if (((*Str > L'7') || (*Str < L'0')) && (Base == 8)) { - return STATUS_INVALID_PARAMETER; + break; } else if (((*Str > L'9') || (*Str < L'0')) && (Base == 10)) { - return STATUS_INVALID_PARAMETER; + break; } else if ( ((*Str > L'9') || (*Str < L'0')) && ((towupper (*Str) > L'F') || (towupper (*Str) < L'A')) && (Base == 16)) { - return STATUS_INVALID_PARAMETER; + break; } Str++; } @@ -748,8 +759,10 @@ RtlUnicodeStringToInteger( Base = 10; while (iswxdigit (*Str) && - (Val = iswdigit (*Str) ? *Str - L'0' : (iswlower (*Str) - ? towupper (*Str) : *Str) - L'A' + 10) < Base) + (Val = + iswdigit (*Str) ? + *Str - L'0' : + (towupper (*Str) - L'A' + 10)) < Base) { *Value = *Value * Base + Val; Str++; @@ -758,7 +771,7 @@ RtlUnicodeStringToInteger( if (addneg == TRUE) *Value *= -1; - return STATUS_SUCCESS; + return Status; }