diff options
author | Anatol Belski <ab@php.net> | 2016-12-22 14:56:47 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2016-12-22 14:56:47 +0100 |
commit | 758af77e9d1c3c6e5aea365bc0d35c385278ad5a (patch) | |
tree | 31a297b9da316030aaacb5ab4382f57ba3e46cca /TSRM | |
parent | afb6ca2566691a673b7e638ffd7e3181e21d80a3 (diff) | |
download | php-git-758af77e9d1c3c6e5aea365bc0d35c385278ad5a.tar.gz |
Path handling related refactorings
Primarily related to the path handling datatypes, to avoid unnecessary
casts, where possible. Also some rework to avoid code dup. Probably
more places are to go, even not path related, primarily to have less
casts and unsigned integers where possible. That way, we've not only
less warnings and casts, but are also safer with regard to the
integer overflows. OFC it's not a panacea, but still significantly
reduces the vulnerability potential.
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/readdir.h | 48 | ||||
-rw-r--r-- | TSRM/tsrm_win32.c | 4 |
2 files changed, 5 insertions, 47 deletions
diff --git a/TSRM/readdir.h b/TSRM/readdir.h index 0665810c85..11c0f31ea1 100644 --- a/TSRM/readdir.h +++ b/TSRM/readdir.h @@ -1,45 +1,3 @@ -#ifndef READDIR_H -#define READDIR_H - - -/* - * Structures and types used to implement opendir/readdir/closedir - * on Windows 95/NT. - */ - -#include <windows.h> - -#include <io.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <direct.h> - -/* struct dirent - same as Unix */ - -struct dirent { - long d_ino; /* inode (always 1 in WIN32) */ - off_t d_off; /* offset to this dirent */ - unsigned short d_reclen; /* length of d_name */ - char d_name[_MAX_FNAME + 1]; /* filename (null terminated) */ -}; - - -/* typedef DIR - not the same as Unix */ -typedef struct { - HANDLE handle; /* _findfirst/_findnext handle */ - short offset; /* offset into directory */ - short finished; /* 1 if there are not more files */ - WIN32_FIND_DATA fileinfo; /* from _findfirst/_findnext */ - char *dir; /* the dir we are reading */ - struct dirent dent; /* the dirent to return */ -} DIR; - -/* Function prototypes */ -DIR *opendir(const char *); -struct dirent *readdir(DIR *); -int readdir_r(DIR *, struct dirent *, struct dirent **); -int closedir(DIR *); -int rewinddir(DIR *); - -#endif /* READDIR_H */ +/* Keep this header for compatibility with external code, it's currently not + used anywhere in the core and there are no implementations in TSRM. */ +#include "win32/readdir.h" diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 7fa38198de..ac9d667788 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -296,14 +296,14 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode) if (CWDG(realpath_cache_size_limit)) { t = time(0); - bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t); + bucket = realpath_cache_lookup(pathname, strlen(pathname), t); if(bucket == NULL && real_path == NULL) { /* We used the pathname directly. Call tsrm_realpath */ /* so that entry is created in realpath cache */ real_path = (char *)malloc(MAXPATHLEN); if(tsrm_realpath(pathname, real_path) != NULL) { pathname = real_path; - bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t); + bucket = realpath_cache_lookup(pathname, strlen(pathname), t); PHP_WIN32_IOUTIL_REINIT_W(pathname); } } |