Opened 8 years ago

Last modified 5 years ago

#11138 new Bugs

filesystem::path::canonical() failed with junction points on Windows

Reported by: yanggehua@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.57.0 Severity: Problem
Keywords: filesystem, path, canonical Cc:

Description

Hi,

In my recent use of filesystem in Boost 1.57, the call of path::canonical() on Windows 7 returns an invalid path if part of the path in question is a junction point.

This failure can be reproduced with the following code:

  // "C:\Gehua" is a junction point of "D:\Gehua"
  fs::path work("d:/Gehua/work");
  fs::path work_canonical(fs::canonical(work));
  std::wstring s = fs::canonical(work_canonical).native();
  // True path passes
  assert(s == L"d:/Gehua\\work");

  // try the junction path 
  fs::path work_junction("c:/Gehua/work");
  // this passes
  assert(fs::exists(work_junction));

  s = fs::canonical(work_junction).native();
  // this one fails!
  // s has value "c:/Gehua\\Gehua\\work"
  assert(s == L"d:/Gehua\\work");

The call returned a value of "c:/Gehua\\Gehua\\work", which was wrong.

Attachments (1)

a.cxx (630 bytes ) - added by anonymous 8 years ago.

Download all attachments as: .zip

Change History (2)

by anonymous, 8 years ago

Attachment: a.cxx added

comment:1 by anonymous, 5 years ago

This is a duplicate of ticket 10900, which outlines the real bug in read_symlink (the wrong element of a union is being read so that first 2 characters of the junction path end up being stripped out, removing the "c:" in your case).

Note: See TracTickets for help on using tickets.