Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73688

Qt doesn't treat UNC paths and NTFS symbolic links correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.4, 5.14.0 Alpha
    • 5.9
    • Core: I/O
    • None
    • Windows, WinRT
    • 3f17029aa12eafd3f8ddd5e0b246a6bf22eabfe3 (qt/qtbase/5.12)

    Description

      This tickets ties various related bug reports together.

      The various methods in QFile/QFileInfo/QDir that try to interpret symbolic links on NTFS in general, and links to UNC paths in particular, are buggy and inconsistent. Windows API specific file name tagging with ?\, ??\, or \\?\UNC\ (which is supposed to enable paths that exceed MAX_PATH) sometimes leaks through Qt APIs to the application code, even though it should be entirely invisible to Qt API users.

      As a general requirement for a fix, Qt APIs that interpret paths or follow links should

      • always generate paths that can be used in other QFile, QDir, etc APIs (ie c:\dir\file is ok; \\server\share\file is ok; ?\server\share\file is not ok)
      • never leak Windows API specific tagging to the API user
         

      The attached code prints

      This is what I know about c:\Users\host
       - fileInfo.isAbsolute true
       - fileInfo.absoluteFilePath C:/Users/host
       - fileInfo.canonicalPath C:/Users/UNC/VBOXSRV
       - fileInfo.canonicalFilePath C:/Users/UNC/VBOXSRV/host
       - fileInfo.isSymLink true
       - fileInfo.symLinkTarget C:/Users/UNC/VBOXSRV/host
       - fileInfo.isDir true
       - entry count: 19
       - dir.canonicalPath C:/Users/UNC/VBOXSRV/host
       - QDir::toNativeSeperators c:\Users\host
       - QDir::cleanPath c:/Users/host
       - storageInfo.rootPath C:/
      

      where c:\Users\host is created with

      mklink /D c:\Users\host \\VBOXSRV\host

       

      Attachments

        1. main.cpp
          2 kB
        2. qtbug73688.zip
          1 kB

        Issue Links

          For Gerrit Dashboard: QTBUG-73688
          # Subject Branch Project Status CR V

          Activity

            People

              vhilshei Volker Hilsheimer
              vhilshei Volker Hilsheimer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes