unsigned int retlength = 0, rname_off = 0;
int bufindex = 0, rname_len = 0, isabsolute = 0;
wchar_t * reparsetarget;
+ WCHAR szVolumePathNames[MAX_PATH];
if(++(*ll) > LINK_MAX) {
return -1;
}
if(isabsolute && rname_len > 4) {
- /* Skip first 4 characters if they are "\\?\" */
- if(reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'\\' &&
- reparsetarget[rname_off + 2] == L'?' && reparsetarget[rname_off + 3] == L'\\') {
- rname_off += 4;
- rname_len -= 4;
- }
- if(reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'?' &&
+ /* Skip first 4 characters if they are "\\?\" and fetch the drive name */
+ if ((reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'\\' &&
+ reparsetarget[rname_off + 2] == L'?' && reparsetarget[rname_off + 3] == L'\\')) {
+ BOOL res;
+
+ res = GetVolumePathNameW(reparsetarget, szVolumePathNames, MAX_PATH);
+ if (!res) {
+ return -1;
+ }
+ reparsetarget = szVolumePathNames;
+ rname_off = 0;
+ rname_len = wcslen(szVolumePathNames);
+ } else
+ /* Skip first 4 characters if they are "\??\"*/
+ if (reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'?' &&
reparsetarget[rname_off + 2] == L'?' && reparsetarget[rname_off + 3] == L'\\') {
rname_off += 4;
rname_len -= 4;
j = bufindex;
if(isabsolute == 1) {
- /* use_realpath is 0 in the call below coz path is absolute*/
- j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory TSRMLS_CC);
- if(j < 0) {
- tsrm_free_alloca(tmp, use_heap);
- return -1;
+ if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
+ /* use_realpath is 0 in the call below coz path is absolute*/
+ j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory TSRMLS_CC);
+ if(j < 0) {
+ tsrm_free_alloca(tmp, use_heap);
+ return -1;
+ }
}
}
else {