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

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

XMLWordPrintable

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

      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

       

        1. qtbug73688.zip
          1 kB
        2. main.cpp
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes