FIX: _AfxFullPath() Uses lstrcpy Incorrectly If Errors Occur

Last reviewed: September 18, 1997
Article ID: Q113258
1.00 WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), included with: Microsoft Visual C++ for Windows, version 1.0

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 MfcDocView kbbuglist kbfixlist kbprg
Technology : kbMfc
Version : 1.00
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.