FIX: _AfxFullPath() Uses lstrcpy Incorrectly If Errors Occur

ID: Q113258

1.00 WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

SYMPTOMS

When an application uses either CWinApp::OpenDocumentFile() or CFile::GetStatus() and passes a filename that includes an invalid path, _AfxFullPath() recognizes the problem but doesn't return the path specified.

CAUSE

In the file AUXDATA.CPP, the following lines are executed within _AfxFullPath() when the path to the file cannot be parsed correctly:

   if (OpenFile(lpszFileIn, &of, OF_PARSE) != HFILE_ERROR)
   {
       ...
   }
   else
   {
    TRACE1("Warning: could not parse the path %Fs\n", lpszFileIn);
       lstrcpy(lpszPathOut, lpszPathOut);  // take it literally
    AnsiUpper(lpszPathOut); // paths in uppercase just to be sure
       return FALSE;
   }

The error occurs on the line containing the lstrcpy function. When the lstrcpy function is executed, it copies the lpszPathOut buffer to itself instead of to lpszPathIn.

RESOLUTION

To solve this problem, replace the second argument of lstrcpy with lpszFileIn in AUXDATA.CPP as shown below:

   lstrcpy(lpszPathOut, lpszPathIn);

After modifying AUXDATA.CPP, rebuild all MFC library variants required. For more information on building MFC library variants, refer to the README.TXT file in the MFC source code directory (by default, MSVC\MFC\SRC).

STATUS

Microsoft has confirmed this to be a problem with version 2.0 of the Microsoft Foundation Class Libraries. This problem was corrected in the Microsoft Foundation Classes version 2.5.

NOTE: This problem does not occur in the Microsoft Foundation Classes version 2.0 included with Visual C++, 32-bit Edition, version 1.0.

Additional reference words: 1.00 2.00 KBCategory: kbprg kbfixlist kbbuglist KBSubcategory: MfcDocView

Keywords          : kb16bitonly kbDocView kbMFC kbVC kbbuglist kbfixlist
Version           : 1.00
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: September 21, 1997