mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 02:36:13 +00:00
Fix GetFullPathNameA/W() return value
svn path=/trunk/; revision=11220
This commit is contained in:
parent
ed6cee0a13
commit
8438655244
1 changed files with 71 additions and 63 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dir.c,v 1.48 2004/08/18 02:13:27 navaraf Exp $
|
||||
/* $Id: dir.c,v 1.49 2004/10/07 20:39:04 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -338,9 +338,10 @@ GetFullPathNameA (
|
|||
{
|
||||
UNICODE_STRING nameW;
|
||||
WCHAR bufferW[MAX_PATH];
|
||||
DWORD ret, retW;
|
||||
DWORD ret;
|
||||
LPWSTR FilePart = NULL;
|
||||
|
||||
if (0 == nBufferLength) __asm__("int $3\n");
|
||||
DPRINT("GetFullPathNameA(lpFileName %s, nBufferLength %d, lpBuffer %p, "
|
||||
"lpFilePart %p)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart);
|
||||
|
||||
|
@ -361,26 +362,22 @@ GetFullPathNameA (
|
|||
*lpFilePart = NULL;
|
||||
}
|
||||
|
||||
retW = GetFullPathNameW(nameW.Buffer, MAX_PATH, bufferW, &FilePart);
|
||||
ret = GetFullPathNameW(nameW.Buffer, MAX_PATH, bufferW, &FilePart);
|
||||
|
||||
if (!retW)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
else if (retW > MAX_PATH)
|
||||
if (MAX_PATH < ret)
|
||||
{
|
||||
SetLastError(ERROR_FILENAME_EXCED_RANGE);
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
else if (0 < ret)
|
||||
{
|
||||
if (ret < nBufferLength)
|
||||
{
|
||||
ANSI_STRING AnsiBuffer;
|
||||
UNICODE_STRING UnicodeBuffer;
|
||||
|
||||
UnicodeBuffer.Length = wcslen(bufferW) * sizeof(WCHAR);
|
||||
ret = nameW.Length;
|
||||
if (nameW.Length <= nBufferLength)
|
||||
{
|
||||
UnicodeBuffer.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
UnicodeBuffer.Buffer = bufferW;
|
||||
AnsiBuffer.MaximumLength = nBufferLength;
|
||||
AnsiBuffer.Length = 0;
|
||||
|
@ -392,6 +389,10 @@ GetFullPathNameA (
|
|||
*lpFilePart = (FilePart - bufferW) + lpBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
|
||||
RtlFreeUnicodeString(&nameW);
|
||||
|
@ -428,7 +429,14 @@ GetFullPathNameW (
|
|||
DPRINT("lpBuffer %S lpFilePart %S Length %ld\n",
|
||||
lpBuffer, (lpFilePart == NULL) ? L"NULL" : *lpFilePart, Length / sizeof(WCHAR));
|
||||
|
||||
return (Length / sizeof(WCHAR));
|
||||
Length = Length / sizeof(WCHAR);
|
||||
if (nBufferLength < Length + 1)
|
||||
{
|
||||
DPRINT("Adjusting Length for terminator\n");
|
||||
Length++;
|
||||
}
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue