You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by st...@apache.org on 2002/11/22 17:19:50 UTC
cvs commit: apr/file_io/win32 filestat.c
stoddard 2002/11/22 08:19:50
Modified: file_io/win32 filestat.c
Log:
Win32: Fix apr_stat() fooness. When passing in a filename like c:/foo/<a>,
the < and > were treated like wildcards and the apr_stat call would succeed
indicating a filename of perhaps 'aaa' if aaa were a directory in c:/foo.
Revision Changes Path
1.70 +16 -0 apr/file_io/win32/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- filestat.c 12 Oct 2002 05:28:16 -0000 1.69
+++ filestat.c 22 Nov 2002 16:19:50 -0000 1.70
@@ -503,6 +503,7 @@
* enough string to handle the longest file name.
*/
char tmpname[APR_FILE_MAX * 3 + 1];
+ const char *name;
HANDLE hFind;
if (strchr(fname, '*') || strchr(fname, '?'))
return APR_ENOENT;
@@ -514,6 +515,13 @@
FileInfo.w.cFileName)) {
return APR_ENAMETOOLONG;
}
+ /* If fname does not match the name returned by FindFirstFile
+ * then fname does not exist and we're done.
+ */
+ name = apr_filepath_name_get(fname);
+ if (strcasecmp(name, tmpname)) {
+ return APR_ENOENT;
+ }
filename = apr_pstrdup(pool, tmpname);
}
}
@@ -554,6 +562,7 @@
* or are looking for the root of a Win98 drive.
*/
HANDLE hFind;
+ const char *name;
if (strchr(fname, '*') || strchr(fname, '?'))
return APR_ENOENT;
hFind = FindFirstFileA(fname, &FileInfo.n);
@@ -561,6 +570,13 @@
return apr_get_os_error();
}
FindClose(hFind);
+ /* If fname does not match the name returned by FindFirstFile
+ * then fname does not exist and we're done.
+ */
+ name = apr_filepath_name_get(fname);
+ if (strcasecmp(name, FileInfo.n.cFileName)) {
+ return APR_ENOENT;
+ }
filename = apr_pstrdup(pool, FileInfo.n.cFileName);
}
#endif