Overview
SHA1 Hash: | a7822bcc001e9fce21a6f97803a02ae221f0cea8 |
---|---|
Date: | 2009-11-14 14:38:10 |
User: | drh |
Comment: | In the file_isdir() routine, make sure the filename is simplified (has no "/../" or "/./" components and does not end with "/") in order to work around bugs in mingw. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/file.c from [7be765ce11] to [8138522279].
@@ -138,14 +138,18 @@ ** does not exist. Return 2 if zFilename exists but is something ** other than a directory. */ int file_isdir(const char *zFilename){ struct stat buf; - if( stat(zFilename, &buf)!=0 ){ - return 0; - } - return S_ISDIR(buf.st_mode) ? 1 : 2; + int rc; + char *zFN; + + zFN = mprintf("%s", zFilename); + file_simplify_name(zFN, strlen(zFN)); + rc = stat(zFN, &buf); + free(zFN); + return rc!=0 ? 0 : (S_ISDIR(buf.st_mode) ? 1 : 2); } /* ** Create the directory named in the argument, if it does not already ** exist. If forceFlag is 1, delete any prior non-directory object @@ -222,15 +226,15 @@ #endif while( n>1 && z[n-1]=='/' ){ n--; } for(i=j=0; i<n; i++){ if( z[i]=='/' ){ if( z[i+1]=='/' ) continue; - if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){ + if( z[i+1]=='.' && (i+2==n || z[i+2]=='/') ){ i += 1; continue; } - if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){ + if( z[i+1]=='.' && i+2<n && z[i+2]=='.' && (i+3==n || z[i+3]=='/') ){ while( j>0 && z[j-1]!='/' ){ j--; } if( j>0 ){ j--; } i += 2; continue; }