"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "file_io/win32/filestat.c" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

filestat.c  (apr-1.6.5.tar.bz2):filestat.c  (apr-1.7.0.tar.bz2)
skipping to change at line 213 skipping to change at line 213
finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE; finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE;
} }
finfo->protection |= (finfo->protection << prot_scope_group) finfo->protection |= (finfo->protection << prot_scope_group)
| (finfo->protection << prot_scope_user); | (finfo->protection << prot_scope_user);
finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT; finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT;
return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS); return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS);
} }
static int reparse_point_is_link(WIN32_FILE_ATTRIBUTE_DATA *wininfo,
int finddata, const char *fname)
{
int tag = 0;
if (!(wininfo->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
{
return 0;
}
if (finddata)
{
// no matter A or W as we don't need file name
tag = ((WIN32_FIND_DATAA*)wininfo)->dwReserved0;
}
else
{
if (test_safe_name(fname) != APR_SUCCESS) {
return 0;
}
#if APR_HAS_UNICODE_FS
IF_WIN_OS_IS_UNICODE
{
apr_wchar_t wfname[APR_PATH_MAX];
HANDLE hFind;
WIN32_FIND_DATAW fd;
if (utf8_to_unicode_path(wfname, APR_PATH_MAX, fname) != APR_SUCCESS
) {
return 0;
}
hFind = FindFirstFileW(wfname, &fd);
if (hFind == INVALID_HANDLE_VALUE) {
return 0;
}
FindClose(hFind);
tag = fd.dwReserved0;
}
#endif
#if APR_HAS_ANSI_FS || 1
ELSE_WIN_OS_IS_ANSI
{
HANDLE hFind;
WIN32_FIND_DATAA fd;
hFind = FindFirstFileA(fname, &fd);
if (hFind == INVALID_HANDLE_VALUE) {
return 0;
}
FindClose(hFind);
tag = fd.dwReserved0;
}
#endif
}
// Test "Name surrogate bit" to detect any kind of symbolic link
// See https://docs.microsoft.com/en-us/windows/desktop/fileio/reparse-point
-tags
return tag & 0x20000000;
}
apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
apr_int32_t wanted, int whatfile) apr_int32_t wanted, int whatfile)
{ {
PSID user = NULL, grp = NULL; PSID user = NULL, grp = NULL;
PACL dacl = NULL; PACL dacl = NULL;
apr_status_t rv; apr_status_t rv;
if (apr_os_level < APR_WIN_NT) if (apr_os_level < APR_WIN_NT)
return guess_protection_bits(finfo, wanted); return guess_protection_bits(finfo, wanted);
skipping to change at line 353 skipping to change at line 418
* passed for wininfo. When the BY_HANDLE_FILE_INFORMATION structure * passed for wininfo. When the BY_HANDLE_FILE_INFORMATION structure
* is passed for wininfo, byhandle is passed as 1 to offset the one * is passed for wininfo, byhandle is passed as 1 to offset the one
* dword discrepancy in offset of the High/Low size structure members. * dword discrepancy in offset of the High/Low size structure members.
* *
* The generic fillin returns 1 if the caller should further inquire * The generic fillin returns 1 if the caller should further inquire
* if this is a CHR filetype. If it's reasonably certain it can't be, * if this is a CHR filetype. If it's reasonably certain it can't be,
* then the function returns 0. * then the function returns 0.
*/ */
int fillin_fileinfo(apr_finfo_t *finfo, int fillin_fileinfo(apr_finfo_t *finfo,
WIN32_FILE_ATTRIBUTE_DATA *wininfo, WIN32_FILE_ATTRIBUTE_DATA *wininfo,
int byhandle, apr_int32_t wanted) int byhandle,
int finddata,
const char *fname,
apr_int32_t wanted)
{ {
DWORD *sizes = &wininfo->nFileSizeHigh + byhandle; DWORD *sizes = &wininfo->nFileSizeHigh + byhandle;
int warn = 0; int warn = 0;
memset(finfo, '\0', sizeof(*finfo)); memset(finfo, '\0', sizeof(*finfo));
FileTimeToAprTime(&finfo->atime, &wininfo->ftLastAccessTime); FileTimeToAprTime(&finfo->atime, &wininfo->ftLastAccessTime);
FileTimeToAprTime(&finfo->ctime, &wininfo->ftCreationTime); FileTimeToAprTime(&finfo->ctime, &wininfo->ftCreationTime);
FileTimeToAprTime(&finfo->mtime, &wininfo->ftLastWriteTime); FileTimeToAprTime(&finfo->mtime, &wininfo->ftLastWriteTime);
#if APR_HAS_LARGE_FILES #if APR_HAS_LARGE_FILES
finfo->size = (apr_off_t)sizes[1] finfo->size = (apr_off_t)sizes[1]
| ((apr_off_t)sizes[0] << 32); | ((apr_off_t)sizes[0] << 32);
#else #else
finfo->size = (apr_off_t)sizes[1]; finfo->size = (apr_off_t)sizes[1];
if (finfo->size < 0 || sizes[0]) if (finfo->size < 0 || sizes[0])
finfo->size = 0x7fffffff; finfo->size = 0x7fffffff;
#endif #endif
if (wanted & APR_FINFO_LINK && if (wanted & APR_FINFO_LINK &&
wininfo->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { reparse_point_is_link(wininfo, finddata, fname)) {
finfo->filetype = APR_LNK; finfo->filetype = APR_LNK;
} }
else if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { else if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
finfo->filetype = APR_DIR; finfo->filetype = APR_DIR;
} }
else if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_DEVICE) { else if (wininfo->dwFileAttributes & FILE_ATTRIBUTE_DEVICE) {
/* Warning: This test only succeeds on Win9x, on NT these files /* Warning: This test only succeeds on Win9x, on NT these files
* (con, aux, nul, lpt#, com# etc) escape early detection! * (con, aux, nul, lpt#, com# etc) escape early detection!
*/ */
finfo->filetype = APR_CHR; finfo->filetype = APR_CHR;
skipping to change at line 450 skipping to change at line 518
finfo->size = size.QuadPart; finfo->size = size.QuadPart;
finfo->valid = APR_FINFO_SIZE; finfo->valid = APR_FINFO_SIZE;
return APR_SUCCESS; return APR_SUCCESS;
} }
if (!GetFileInformationByHandle(thefile->filehand, &FileInfo)) { if (!GetFileInformationByHandle(thefile->filehand, &FileInfo)) {
return apr_get_os_error(); return apr_get_os_error();
} }
fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, 1, wanted); fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, 1, 0, thefil e->fname, wanted);
if (finfo->filetype == APR_REG) if (finfo->filetype == APR_REG)
{ {
/* Go the extra mile to be -certain- that we have a real, regular /* Go the extra mile to be -certain- that we have a real, regular
* file, since the attribute bits aren't a certain thing. Even * file, since the attribute bits aren't a certain thing. Even
* though fillin should have hinted if we *must* do this, we * though fillin should have hinted if we *must* do this, we
* don't need to take chances while the handle is already open. * don't need to take chances while the handle is already open.
*/ */
DWORD FileType; DWORD FileType;
if ((FileType = GetFileType(thefile->filehand))) { if ((FileType = GetFileType(thefile->filehand))) {
skipping to change at line 521 skipping to change at line 589
apr_wchar_t wfname[APR_PATH_MAX]; apr_wchar_t wfname[APR_PATH_MAX];
#endif #endif
char *filename = NULL; char *filename = NULL;
/* These all share a common subset of this structure */ /* These all share a common subset of this structure */
union { union {
WIN32_FIND_DATAW w; WIN32_FIND_DATAW w;
WIN32_FIND_DATAA n; WIN32_FIND_DATAA n;
WIN32_FILE_ATTRIBUTE_DATA i; WIN32_FILE_ATTRIBUTE_DATA i;
} FileInfo; } FileInfo;
int finddata = 0;
/* Catch fname length == MAX_PATH since GetFileAttributesEx fails /* Catch fname length == MAX_PATH since GetFileAttributesEx fails
* with PATH_NOT_FOUND. We would rather indicate length error than * with PATH_NOT_FOUND. We would rather indicate length error than
* 'not found' * 'not found'
*/ */
if (strlen(fname) >= APR_PATH_MAX) { if (strlen(fname) >= APR_PATH_MAX) {
return APR_ENAMETOOLONG; return APR_ENAMETOOLONG;
} }
#if APR_HAS_UNICODE_FS #if APR_HAS_UNICODE_FS
skipping to change at line 556 skipping to change at line 625
if ((ident_rv = resolve_ident(finfo, fname, wanted, pool)) if ((ident_rv = resolve_ident(finfo, fname, wanted, pool))
== APR_SUCCESS) == APR_SUCCESS)
return ident_rv; return ident_rv;
else if (ident_rv == APR_INCOMPLETE) else if (ident_rv == APR_INCOMPLETE)
wanted &= ~finfo->valid; wanted &= ~finfo->valid;
} }
if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname)
/ sizeof(apr_wchar_t), fname))) / sizeof(apr_wchar_t), fname)))
return rv; return rv;
if (!(wanted & APR_FINFO_NAME)) { if (!(wanted & (APR_FINFO_NAME | APR_FINFO_LINK))) {
if (!GetFileAttributesExW(wfname, GetFileExInfoStandard, if (!GetFileAttributesExW(wfname, GetFileExInfoStandard,
&FileInfo.i)) &FileInfo.i))
return apr_get_os_error(); return apr_get_os_error();
} }
else { else {
/* Guard against bogus wildcards and retrieve by name /* Guard against bogus wildcards and retrieve by name
* since we want the true name, and set aside a long * since we want the true name, and set aside a long
* enough string to handle the longest file name. * enough string to handle the longest file name.
*/ */
char tmpname[APR_FILE_MAX * 3 + 1];
HANDLE hFind; HANDLE hFind;
if ((rv = test_safe_name(fname)) != APR_SUCCESS) { if ((rv = test_safe_name(fname)) != APR_SUCCESS) {
return rv; return rv;
} }
hFind = FindFirstFileW(wfname, &FileInfo.w); hFind = FindFirstFileW(wfname, &FileInfo.w);
if (hFind == INVALID_HANDLE_VALUE) if (hFind == INVALID_HANDLE_VALUE)
return apr_get_os_error(); return apr_get_os_error();
FindClose(hFind); FindClose(hFind);
if (unicode_to_utf8_path(tmpname, sizeof(tmpname), finddata = 1;
FileInfo.w.cFileName)) {
return APR_ENAMETOOLONG; if (wanted & APR_FINFO_NAME)
{
char tmpname[APR_FILE_MAX * 3 + 1];
if (unicode_to_utf8_path(tmpname, sizeof(tmpname),
FileInfo.w.cFileName)) {
return APR_ENAMETOOLONG;
}
filename = apr_pstrdup(pool, tmpname);
} }
filename = apr_pstrdup(pool, tmpname);
} }
} }
#endif #endif
#if APR_HAS_ANSI_FS #if APR_HAS_ANSI_FS
ELSE_WIN_OS_IS_ANSI ELSE_WIN_OS_IS_ANSI
{ {
char *root = NULL; char *root = NULL;
const char *test = fname; const char *test = fname;
rv = apr_filepath_root(&root, &test, APR_FILEPATH_NATIVE, pool); rv = apr_filepath_root(&root, &test, APR_FILEPATH_NATIVE, pool);
isroot = (root && *root && !(*test)); isroot = (root && *root && !(*test));
if ((apr_os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) || isroo t)) if ((apr_os_level >= APR_WIN_98) && (!(wanted & (APR_FINFO_NAME | APR_FI NFO_LINK)) || isroot))
{ {
/* cannot use FindFile on a Win98 root, it returns \* /* cannot use FindFile on a Win98 root, it returns \*
* GetFileAttributesExA is not available on Win95 * GetFileAttributesExA is not available on Win95
*/ */
if (!GetFileAttributesExA(fname, GetFileExInfoStandard, if (!GetFileAttributesExA(fname, GetFileExInfoStandard,
&FileInfo.i)) { &FileInfo.i)) {
return apr_get_os_error(); return apr_get_os_error();
} }
} }
else if (isroot) { else if (isroot) {
skipping to change at line 633 skipping to change at line 707
* since we want the true name, or are stuck in Win95, * since we want the true name, or are stuck in Win95,
* or are looking for the root of a Win98 drive. * or are looking for the root of a Win98 drive.
*/ */
HANDLE hFind; HANDLE hFind;
if ((rv = test_safe_name(fname)) != APR_SUCCESS) { if ((rv = test_safe_name(fname)) != APR_SUCCESS) {
return rv; return rv;
} }
hFind = FindFirstFileA(fname, &FileInfo.n); hFind = FindFirstFileA(fname, &FileInfo.n);
if (hFind == INVALID_HANDLE_VALUE) { if (hFind == INVALID_HANDLE_VALUE) {
return apr_get_os_error(); return apr_get_os_error();
} }
FindClose(hFind); FindClose(hFind);
filename = apr_pstrdup(pool, FileInfo.n.cFileName); finddata = 1;
if (wanted & APR_FINFO_NAME) {
filename = apr_pstrdup(pool, FileInfo.n.cFileName);
}
} }
} }
#endif #endif
if (ident_rv != APR_INCOMPLETE) { if (ident_rv != APR_INCOMPLETE) {
if (fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, if (fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo,
0, wanted)) 0, finddata, fname, wanted))
{ {
/* Go the extra mile to assure we have a file. WinNT/2000 seems /* Go the extra mile to assure we have a file. WinNT/2000 seems
* to reliably translate char devices to the path '\\.\device' * to reliably translate char devices to the path '\\.\device'
* so go ask for the full path. * so go ask for the full path.
*/ */
if (apr_os_level >= APR_WIN_NT) if (apr_os_level >= APR_WIN_NT)
{ {
#if APR_HAS_UNICODE_FS #if APR_HAS_UNICODE_FS
apr_wchar_t tmpname[APR_FILE_MAX]; apr_wchar_t tmpname[APR_FILE_MAX];
apr_wchar_t *tmpoff = NULL; apr_wchar_t *tmpoff = NULL;
 End of changes. 13 change blocks. 
13 lines changed or deleted 92 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)