Author: ion
Date: Mon Nov 7 05:07:58 2011
New Revision: 54332
URL:
http://svn.reactos.org/svn/reactos?rev=54332&view=rev
Log:
[KERNEL32]: Fix multiple, multiple, bugs in the last commits. Path is now down to 12
failures (way lower than before the streak), most unrelated to actual path APIs.
Modified:
trunk/reactos/dll/win32/kernel32/client/path.c
Modified: trunk/reactos/dll/win32/kernel32/client/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/path.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/path.c [iso-8859-1] Mon Nov 7 05:07:58 2011
@@ -144,10 +144,13 @@
for (i = 0, Dots = Length - 1; i < Length; i++, Dots--)
{
/* Check if this could be an extension */
- if (*FileName == '.')
+ if (FileName[i] == '.')
{
/* Unlike the short case, we WANT more than one extension, or a long one */
- if ((HasExtension) || (Dots > 3)) return TRUE;
+ if ((HasExtension) || (Dots > 3))
+ {
+ return TRUE;
+ }
HasExtension = TRUE;
}
@@ -219,7 +222,7 @@
PWCHAR
WINAPI
-SkipPathTypeIndicator_U(IN PWCHAR Path)
+SkipPathTypeIndicator_U(IN LPWSTR Path)
{
PWCHAR ReturnPath;
ULONG i;
@@ -543,7 +546,7 @@
if (!PathSize) goto Quickie;
/* If the *caller's* buffer was too small, fail, but add in space for NULL */
- if (PathSize < nBufferLength)
+ if (PathSize >= nBufferLength)
{
PathSize++;
goto Quickie;
@@ -890,7 +893,7 @@
HANDLE FindHandle;
DWORD ReturnLength;
ULONG ErrorMode;
- BOOLEAN Found;
+ BOOLEAN Found = FALSE;
WIN32_FIND_DATAW FindFileData;
/* Initialize so Quickie knows there's nothing to do */
@@ -917,13 +920,12 @@
}
/* Now get a pointer to the actual path, skipping indicators */
- Path = SkipPathTypeIndicator_U((PWCHAR)lpszShortPath);
-
- /* Try to find a file name in there */
- if (Path) Found = FindLFNorSFN_U(Path, &First, &Last, FALSE);
+ Path = SkipPathTypeIndicator_U((LPWSTR)lpszShortPath);
/* Is there any path or filename in there? */
- if (!(Path) || (*Path == UNICODE_NULL) || !(Found))
+ if (!(Path) ||
+ (*Path == UNICODE_NULL) ||
+ !(FindLFNorSFN_U(Path, &First, &Last, FALSE)))
{
/* There isn't, so the long path is simply the short path */
ReturnLength = wcslen(lpszShortPath);
@@ -953,7 +955,7 @@
Original = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
if (!Original) goto ErrorQuickie;
- /* Make a copy ofi t */
+ /* Make a copy of it */
RtlMoveMemory(Original, lpszShortPath, Length * sizeof(WCHAR));
/* Compute the new first and last markers */
@@ -1269,7 +1271,7 @@
HANDLE FindHandle;
DWORD ReturnLength;
ULONG ErrorMode;
- BOOLEAN Found;
+ BOOLEAN Found = FALSE;
WIN32_FIND_DATAW FindFileData;
/* Initialize so Quickie knows there's nothing to do */
@@ -1288,7 +1290,7 @@
ErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
/* Do a simple check to see if the path exists */
- if (GetFileAttributesW(lpszShortPath) == INVALID_FILE_ATTRIBUTES)
+ if (GetFileAttributesW(lpszLongPath) == INVALID_FILE_ATTRIBUTES)
{
/* Windows checks for an application compatibility flag to allow this */
if (!(NtCurrentPeb()) || !(NtCurrentPeb()->AppCompatFlags.LowPart & 1))
@@ -1300,19 +1302,18 @@
}
/* Now get a pointer to the actual path, skipping indicators */
- Path = SkipPathTypeIndicator_U((PWCHAR)lpszShortPath);
-
- /* Try to find a file name in there */
- if (Path) Found = FindLFNorSFN_U(Path, &First, &Last, TRUE);
+ Path = SkipPathTypeIndicator_U((LPWSTR)lpszLongPath);
/* Is there any path or filename in there? */
- if (!(Path) || (*Path == UNICODE_NULL) || !(Found))
+ if (!(Path) ||
+ (*Path == UNICODE_NULL) ||
+ !(FindLFNorSFN_U(Path, &First, &Last, TRUE)))
{
/* There isn't, so the long path is simply the short path */
ReturnLength = wcslen(lpszLongPath);
/* Is there space for it? */
- if ((cchBuffer > ReturnLength) && (lpszLongPath))
+ if ((cchBuffer > ReturnLength) && (lpszShortPath))
{
/* Make sure the pointers aren't already the same */
if (lpszLongPath != lpszShortPath)