tbuffer[0] = *(drivep - 1);
tbuffer[1] = ':';
strcpy(tbuffer + 2, SMB_IOCTL_FILENAME);
+ } else if (fileNamep[0] == fileNamep[1] &&
+ fileNamep[0] == '\\')
+ {
+ int count = 0, i = 0;
+
+ while (count < 4 && fileNamep[i]) {
+ tbuffer[i] = fileNamep[i];
+ if ( tbuffer[i++] == '\\' )
+ count++;
+ }
+ if (fileNamep[i] == 0)
+ tbuffer[i++] = '\\';
+ tbuffer[i] = 0;
+ strcat(tbuffer, SMB_IOCTL_FILENAME);
} else {
char curdir[256]="";
tbuffer[0] = curdir[0];
tbuffer[1] = ':';
strcpy(tbuffer + 2, SMB_IOCTL_FILENAME);
+ } else if (curdir[0] == curdir[1] &&
+ curdir[0] == '\\')
+ {
+ int count = 0, i = 0;
+
+ while (count < 4 && curdir[i]) {
+ tbuffer[i] = curdir[i];
+ if ( tbuffer[i++] == '\\' )
+ count++;
+ }
+ if (tbuffer[i] == 0)
+ tbuffer[i++] = '\\';
+ tbuffer[i] = 0;
+ strcat(tbuffer, SMB_IOCTL_FILENAME_NOSLASH);
}
}
}
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_WRITE_THROUGH, NULL);
fflush(stdout);
- if (fh == INVALID_HANDLE_VALUE)
- return -1;
-
+ if (fh == INVALID_HANDLE_VALUE) {
+ if (GetLastError() == ERROR_DOWNGRADE_DETECTED)
+ fprintf(stderr, "Unable to open \"%s\": Authentication Downgrade Detected\n", tbuffer);
+ return -1;
+ }
/* return fh and success code */
*handlep = fh;
return 0;
pathHasDrive = 0;
}
- if (*firstp == '\\' || *firstp == '/') {
- /* already an absolute pathname, just copy it back */
- strcpy(outPathp, firstp);
- return 0;
+ if ( firstp[0] == '\\' && firstp[1] == '\\') {
+ /* UNC path - strip off the server and sharename */
+ int i, count;
+ for ( i=2,count=2; count < 4 && firstp[i]; i++ ) {
+ if ( firstp[i] == '\\' || firstp[i] == '/' ) {
+ count++;
+ }
+ }
+ if ( firstp[i] == 0 ) {
+ strcpy(outPathp,"\\");
+ } else {
+ strcpy(outPathp,&firstp[--i]);
+ }
+ return 0;
+ } else if (firstp[0] == '\\' || firstp[0] == '/') {
+ /* already an absolute pathname, just copy it back */
+ strcpy(outPathp, firstp);
+ return 0;
}
GetCurrentDirectory(sizeof(origPath), origPath);
GetCurrentDirectory(sizeof(tpath), tpath);
if (tpath[1] == ':')
strcpy(outPathp, tpath + 2); /* skip drive letter */
- else
- strcpy(outPathp, tpath); /* copy entire UNC path */
+ else if ( tpath[0] == '\\' && tpath[1] == '\\') {
+ /* UNC path - strip off the server and sharename */
+ int i, count;
+ for ( i=2,count=2; count < 4 && tpath[i]; i++ ) {
+ if ( tpath[i] == '\\' || tpath[i] == '/' ) {
+ count++;
+ }
+ }
+ if ( tpath[i] == 0 ) {
+ strcpy(outPathp,"\\");
+ } else {
+ strcpy(outPathp,&tpath[--i]);
+ }
+ } else {
+ /* this should never happen */
+ strcpy(outPathp, tpath);
+ }
+
/* if there is a non-null name after the drive, append it */
if (*firstp != 0) {
int len = strlen(outPathp);