Index: lib/rtl/path.c =================================================================== --- lib/rtl/path.c (révision 62608) +++ lib/rtl/path.c (copie de travail) @@ -10,7 +10,7 @@ * Pierre Schweitzer (pierre@reactos.org) */ -/* INCLUDES *****************************************************************/ +/* INCLUDES *******************************************************************/ #include @@ -294,10 +294,11 @@ * 2) Get rid of duplicate backslashes * 3) Get rid of . and .. components in the path. */ -static VOID -RtlpCollapsePath(PWSTR path, ULONG mark, BOOLEAN SkipTrailingPathSeparators) +static VOID // ULONG +RtlpCollapsePath(PWSTR path, /* ULONG PathBufferSize, ULONG PathLength, */ ULONG mark, BOOLEAN SkipTrailingPathSeparators) { PWSTR p, next; + /**/ PWSTR end = path + wcslen(path); // path + PathBufferSize / sizeof(WCHAR); /**/ /* convert every / into a \ */ for (p = path; *p; p++) @@ -318,12 +319,12 @@ { if (*p == L'.') { - switch(p[1]) + switch (p[1]) { case UNICODE_NULL: /* final . */ if (p > path + mark) p--; *p = UNICODE_NULL; - continue; + continue; // Makes the while() loop breaking. case L'\\': /* .\ component */ next = p + 2; RtlMoveMemory( p, next, (wcslen(next) + 1) * sizeof(WCHAR) ); @@ -369,14 +370,21 @@ /* Remove trailing backslashes if needed (after the UNC part if it exists) */ if (SkipTrailingPathSeparators) { - while (p > path + mark && IS_PATH_SEPARATOR(p[-1])) *p-- = UNICODE_NULL; + while (p > path + mark && IS_PATH_SEPARATOR(p[-1])) p--; // *p-- = UNICODE_NULL; } /* Remove trailing spaces and dots (for all the path) */ - while (p > path && (p[-1] == L' ' || p[-1] == L'.')) *p-- = UNICODE_NULL; + while (p > path /**/ + mark /**/ && (p[-1] == L' ' || p[-1] == L'.')) p--; // *p-- = UNICODE_NULL; + /* Zero-out the discarded zone (which starts at p) */ + DPRINT1("p = 0x%p ; end = 0x%p\n", p, end); + ASSERT(end >= p); + RtlZeroMemory(p, (end - p) * sizeof(WCHAR)); + /* Null-terminate the string */ *p = UNICODE_NULL; + + // return (wcslen(path) * sizeof(WCHAR)); } /****************************************************************** @@ -619,7 +627,7 @@ * FIXME: Win2k seems to check that the environment * variable actually points to an existing directory. * If not, root of the drive is used (this seems also - * to be the only spot in RtlGetFullPathName that the + * to be the only place in RtlGetFullPathName that the * existence of a part of a path is checked). */ EnvVarValue.Buffer[EnvVarValue.Length / sizeof(WCHAR)] = L'\\'; @@ -730,10 +738,11 @@ * i.e. simplify redundant . and .., etc... */ // if (*PathType == RtlPathTypeUncAbsolute) DPRINT1("RtlpCollapsePath('%S', %lu)\n", Buffer, PrefixCut); - RtlpCollapsePath(Buffer, PrefixCut, SkipTrailingPathSeparators); + RtlpCollapsePath(Buffer, /* Size, reqsize, */ PrefixCut, SkipTrailingPathSeparators); // if (ShortName) DPRINT1("buffer(4) = %S\n", Buffer); /* Get the length of the full path name, without its terminating null character */ + // TODO: can be e.g. returned by (or given to & returned by) RtlpCollapsePath ... reqsize = wcslen(Buffer) * sizeof(WCHAR); /* Find the file part, which is present after the last path separator */ @@ -761,7 +770,8 @@ Quit: /* Release PEB lock */ RtlReleasePebLock(); - return (ULONG)reqsize; + + return reqsize; } NTSTATUS