Fix name length handing in RtlQueryAtomInAtomTable.
authorFilip Navara <filip.navara@gmail.com>
Wed, 3 Aug 2005 14:45:39 +0000 (14:45 +0000)
committerFilip Navara <filip.navara@gmail.com>
Wed, 3 Aug 2005 14:45:39 +0000 (14:45 +0000)
svn path=/trunk/; revision=16999

reactos/lib/rtl/atom.c

index 4d49278..0c777ca 100644 (file)
@@ -602,19 +602,10 @@ RtlQueryAtomInAtomTable(PRTL_ATOM_TABLE AtomTable,
 
              if (*NameLength < Length + sizeof(WCHAR))
                {
 
              if (*NameLength < Length + sizeof(WCHAR))
                {
-                  /* prevent underflow! */
-                  if (*NameLength >= sizeof(WCHAR))
-                    {
-                       Length = *NameLength - sizeof(WCHAR);
-                    }
-                  else
-                    {
-                       Length = 0;
-                       Status = STATUS_BUFFER_TOO_SMALL;
-                    }
+                  *NameLength = Length;
+                  Status = STATUS_BUFFER_TOO_SMALL;
                }
                }
-
-             if (Length)
+             else 
                {
                   RtlCopyMemory(AtomName,
                                 NameString,
                {
                   RtlCopyMemory(AtomName,
                                 NameString,
@@ -652,19 +643,10 @@ RtlQueryAtomInAtomTable(PRTL_ATOM_TABLE AtomTable,
 
              if (*NameLength < Length + sizeof(WCHAR))
                {
 
              if (*NameLength < Length + sizeof(WCHAR))
                {
-                  /* prevent underflow! */
-                  if (*NameLength >= sizeof(WCHAR))
-                    {
-                       Length = *NameLength - sizeof(WCHAR);
-                    }
-                  else
-                    {
-                       Length = 0;
-                       Status = STATUS_BUFFER_TOO_SMALL;
-                    }
+                  *NameLength = Length;
+                  Status = STATUS_BUFFER_TOO_SMALL;
                }
                }
-
-             if (Length)
+             else
                {
                   RtlCopyMemory(AtomName,
                                 Entry->Name,
                {
                   RtlCopyMemory(AtomName,
                                 Entry->Name,