comparison liboctave/system/file-ops.cc @ 31196:4c38cf0ce06c stable

canonicalize_file_name: Check root of potential mapped network drive (bug #62847). * liboctave/system/file-ops.cc (canonicalize_file_name): Make sure to compare with the canonicalized path corresponding to the root of the drive when checking if a file is on a mapped network drive.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 23 Aug 2022 19:44:16 +0200
parents 84df79fb637d
children f111d1caa73d
comparison
equal deleted inserted replaced
31193:6bcc5e6d77fe 31196:4c38cf0ce06c
748 { 748 {
749 retval = retval.erase (2, 6); 749 retval = retval.erase (2, 6);
750 750
751 // If the initial path looked like a mapped network drive, replace 751 // If the initial path looked like a mapped network drive, replace
752 // portion of path that corresponds to mapped root with drive root. 752 // portion of path that corresponds to mapped root with drive root.
753 if (name.size () < 2 || name[1] != ':') 753 if (name.size () < 3 || name[1] != ':')
754 return retval; 754 return retval;
755 755
756 // UNC path corresponding to original drive letter (mappped drive) 756 // UNC path corresponding to original drive letter (mappped drive)
757 std::wstring orig_map = wname.substr (0, 2); 757 std::wstring orig_map = wname.substr (0, 3);
758 orig_map[2] = L'\\';
758 HANDLE h_map = CreateFileW (orig_map.c_str (), GENERIC_READ, 759 HANDLE h_map = CreateFileW (orig_map.c_str (), GENERIC_READ,
759 FILE_SHARE_READ, nullptr, OPEN_EXISTING, 760 FILE_SHARE_READ, nullptr, OPEN_EXISTING,
760 FILE_FLAG_BACKUP_SEMANTICS 761 FILE_FLAG_BACKUP_SEMANTICS
761 | FILE_FLAG_OPEN_REPARSE_POINT, 762 | FILE_FLAG_OPEN_REPARSE_POINT,
762 nullptr); 763 nullptr);