Initialise zend_stat_t to fix MSAN build

This commit is contained in:
George Peter Banyard 2022-05-22 16:06:27 +01:00
parent cc506a81e1
commit 2ecd46f48f
No known key found for this signature in database
GPG key ID: 3306078E3194AEBD
17 changed files with 29 additions and 29 deletions

View file

@ -120,7 +120,7 @@ static cwd_state main_cwd_state; /* True global */
static int php_is_dir_ok(const cwd_state *state) /* {{{ */ static int php_is_dir_ok(const cwd_state *state) /* {{{ */
{ {
zend_stat_t buf; zend_stat_t buf = {0};
if (php_sys_stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode)) if (php_sys_stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode))
return (0); return (0);
@ -131,7 +131,7 @@ static int php_is_dir_ok(const cwd_state *state) /* {{{ */
static int php_is_file_ok(const cwd_state *state) /* {{{ */ static int php_is_file_ok(const cwd_state *state) /* {{{ */
{ {
zend_stat_t buf; zend_stat_t buf = {0};
if (php_sys_stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode)) if (php_sys_stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode))
return (0); return (0);

View file

@ -4376,7 +4376,7 @@ static bool exif_discard_imageinfo(image_info_type *ImageInfo)
static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream, int read_thumbnail, int read_all) static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream, int read_thumbnail, int read_all)
{ {
bool ret; bool ret;
zend_stat_t st; zend_stat_t st = {0};
/* Start with an empty image information structure. */ /* Start with an empty image information structure. */
memset(ImageInfo, 0, sizeof(*ImageInfo)); memset(ImageInfo, 0, sizeof(*ImageInfo));

View file

@ -1187,7 +1187,7 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
continue; continue;
} }
if ((*bang[i].fun)(ms, &me, if ((*bang[i].fun)(ms, &me,
line + bang[i].len + 2, line + bang[i].len + 2,
len - bang[i].len - 2) != 0) { len - bang[i].len - 2) != 0) {
(*errs)++; (*errs)++;
continue; continue;
@ -1324,7 +1324,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int action)
uint32_t i, j; uint32_t i, j;
size_t files = 0, maxfiles = 0; size_t files = 0, maxfiles = 0;
char **filearr = NULL; char **filearr = NULL;
zend_stat_t st; zend_stat_t st = {0};
struct magic_map *map; struct magic_map *map;
struct magic_entry_set mset[MAGIC_SETS]; struct magic_entry_set mset[MAGIC_SETS];
php_stream *dir; php_stream *dir;
@ -1419,7 +1419,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int action)
/* coalesce per file arrays into a single one, if needed */ /* coalesce per file arrays into a single one, if needed */
if (mset[j].count == 0) if (mset[j].count == 0)
continue; continue;
if (coalesce_entries(ms, mset[j].me, mset[j].count, if (coalesce_entries(ms, mset[j].me, mset[j].count,
&map->magic[j], &map->nmagic[j]) == -1) { &map->magic[j], &map->nmagic[j]) == -1) {
errs++; errs++;

View file

@ -188,7 +188,7 @@ file_or_stream(struct magic_set *ms, const char *inname, php_stream *stream)
{ {
int rv = -1; int rv = -1;
unsigned char *buf; unsigned char *buf;
zend_stat_t sb; zend_stat_t sb = {0};
ssize_t nbytes = 0; /* number of bytes read from a datafile */ ssize_t nbytes = 0; /* number of bytes read from a datafile */
int no_in_stream = 0; int no_in_stream = 0;

View file

@ -2364,7 +2364,7 @@ static X509_STORE *php_openssl_setup_verify(zval *calist)
X509_LOOKUP * dir_lookup, * file_lookup; X509_LOOKUP * dir_lookup, * file_lookup;
int ndirs = 0, nfiles = 0; int ndirs = 0, nfiles = 0;
zval * item; zval * item;
zend_stat_t sb; zend_stat_t sb = {0};
store = X509_STORE_new(); store = X509_STORE_new();

View file

@ -283,7 +283,7 @@ static int ps_files_cleanup_dir(const char *dirname, zend_long maxlifetime)
{ {
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;
zend_stat_t sbuf; zend_stat_t sbuf = {0};
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
time_t now; time_t now;
int nrdels = 0; int nrdels = 0;
@ -340,7 +340,7 @@ static int ps_files_cleanup_dir(const char *dirname, zend_long maxlifetime)
static int ps_files_key_exists(ps_files *data, const char *key) static int ps_files_key_exists(ps_files *data, const char *key)
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
zend_stat_t sbuf; zend_stat_t sbuf = {0};
if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) { if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) {
return FAILURE; return FAILURE;
@ -473,7 +473,7 @@ PS_CLOSE_FUNC(files)
PS_READ_FUNC(files) PS_READ_FUNC(files)
{ {
zend_long n = 0; zend_long n = 0;
zend_stat_t sbuf; zend_stat_t sbuf = {0};
PS_FILES_DATA; PS_FILES_DATA;
ps_files_open(data, ZSTR_VAL(key)); ps_files_open(data, ZSTR_VAL(key));

View file

@ -1153,7 +1153,7 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */
static inline void last_modified(void) /* {{{ */ static inline void last_modified(void) /* {{{ */
{ {
const char *path; const char *path;
zend_stat_t sb; zend_stat_t sb = {0};
char buf[MAX_STR + 1]; char buf[MAX_STR + 1];
path = SG(request_info).path_translated; path = SG(request_info).path_translated;

View file

@ -50,7 +50,7 @@
/* {{{ php_statpage */ /* {{{ php_statpage */
PHPAPI void php_statpage(void) PHPAPI void php_statpage(void)
{ {
zend_stat_t *pstat; zend_stat_t *pstat = {0};
pstat = sapi_get_stat(); pstat = sapi_get_stat();

View file

@ -392,7 +392,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
#if defined(S_IFSOCK) && !defined(PHP_WIN32) #if defined(S_IFSOCK) && !defined(PHP_WIN32)
do { do {
zend_stat_t st; zend_stat_t st = {0};
memset(&st, 0, sizeof(st)); memset(&st, 0, sizeof(st));
if (zend_fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) { if (zend_fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
stream = php_stream_sock_open_from_socket(fd, NULL); stream = php_stream_sock_open_from_socket(fd, NULL);

View file

@ -155,7 +155,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
dir_len = php_dirname(file_dirname, strlen(source)); dir_len = php_dirname(file_dirname, strlen(source));
if (dir_len > 0) { if (dir_len > 0) {
zend_stat_t buf; zend_stat_t buf = {0};
if (php_sys_stat(file_dirname, &buf) != 0) { if (php_sys_stat(file_dirname, &buf) != 0) {
xmlFreeURI(uri); xmlFreeURI(uri);
return NULL; return NULL;

View file

@ -685,7 +685,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v
* able to filter directories out. * able to filter directories out.
*/ */
if (flags & GLOB_ONLYDIR) { if (flags & GLOB_ONLYDIR) {
zend_stat_t s; zend_stat_t s = {0};
if (0 != VCWD_STAT(globbuf.gl_pathv[n], &s)) { if (0 != VCWD_STAT(globbuf.gl_pathv[n], &s)) {
continue; continue;
@ -757,7 +757,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
/* only the files, directories are ignored */ /* only the files, directories are ignored */
for (i = 0; i < files_cnt; i++) { for (i = 0; i < files_cnt; i++) {
zend_stat_t s; zend_stat_t s = {0};
char fullpath[MAXPATHLEN]; char fullpath[MAXPATHLEN];
size_t namelist_len = ZSTR_LEN(namelist[i]); size_t namelist_len = ZSTR_LEN(namelist[i]);
@ -1482,7 +1482,7 @@ PHP_METHOD(ZipArchive, open)
#else #else
if ((flags & ZIP_TRUNCATE) == 0) { if ((flags & ZIP_TRUNCATE) == 0) {
#endif #endif
zend_stat_t st; zend_stat_t st = {0};
/* exists and is empty */ /* exists and is empty */
if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) { if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) {

View file

@ -363,7 +363,7 @@ static void php_binary_init(void)
if ((envpath = getenv("PATH")) != NULL) { if ((envpath = getenv("PATH")) != NULL) {
char *search_dir, search_path[MAXPATHLEN]; char *search_dir, search_path[MAXPATHLEN];
char *last = NULL; char *last = NULL;
zend_stat_t s; zend_stat_t s = {0};
path = estrdup(envpath); path = estrdup(envpath);
search_dir = php_strtok_r(path, ":", &last); search_dir = php_strtok_r(path, ":", &last);
@ -1397,7 +1397,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c
/* {{{ php_get_current_user */ /* {{{ php_get_current_user */
PHPAPI char *php_get_current_user(void) PHPAPI char *php_get_current_user(void)
{ {
zend_stat_t *pstat; zend_stat_t *pstat = {0};
if (SG(request_info).current_user) { if (SG(request_info).current_user) {
return SG(request_info).current_user; return SG(request_info).current_user;

View file

@ -768,7 +768,7 @@ void php_ini_register_extensions(void)
/* {{{ php_parse_user_ini_file */ /* {{{ php_parse_user_ini_file */
PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash) PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash)
{ {
zend_stat_t sb; zend_stat_t sb = {0};
char ini_file[MAXPATHLEN]; char ini_file[MAXPATHLEN];
snprintf(ini_file, MAXPATHLEN, "%s%c%s", dirname, DEFAULT_SLASH, ini_filename); snprintf(ini_file, MAXPATHLEN, "%s%c%s", dirname, DEFAULT_SLASH, ini_filename);

View file

@ -1210,7 +1210,7 @@ static void init_request_info(fcgi_request *request)
#endif #endif
if (CGIG(fix_pathinfo)) { if (CGIG(fix_pathinfo)) {
zend_stat_t st; zend_stat_t st = {0};
char *real_path = NULL; char *real_path = NULL;
char *env_redirect_url = CGI_GETENV("REDIRECT_URL"); char *env_redirect_url = CGI_GETENV("REDIRECT_URL");
char *env_document_root = CGI_GETENV("DOCUMENT_ROOT"); char *env_document_root = CGI_GETENV("DOCUMENT_ROOT");

View file

@ -268,7 +268,7 @@ PHP_FUNCTION(phpdbg_exec)
} }
{ {
zend_stat_t sb; zend_stat_t sb = {0};
bool result = 1; bool result = 1;
if (VCWD_STAT(ZSTR_VAL(exec), &sb) != FAILURE) { if (VCWD_STAT(ZSTR_VAL(exec), &sb) != FAILURE) {

View file

@ -306,7 +306,7 @@ void phpdbg_string_init(char *buffer) {
void phpdbg_try_file_init(char *init_file, size_t init_file_len, bool free_init) /* {{{ */ void phpdbg_try_file_init(char *init_file, size_t init_file_len, bool free_init) /* {{{ */
{ {
zend_stat_t sb; zend_stat_t sb = {0};
if (init_file && VCWD_STAT(init_file, &sb) != -1) { if (init_file && VCWD_STAT(init_file, &sb) != -1) {
FILE *fp = fopen(init_file, "r"); FILE *fp = fopen(init_file, "r");
@ -398,7 +398,7 @@ void phpdbg_clean(bool full, bool resubmit) /* {{{ */
PHPDBG_COMMAND(exec) /* {{{ */ PHPDBG_COMMAND(exec) /* {{{ */
{ {
zend_stat_t sb; zend_stat_t sb = {0};
if (VCWD_STAT(param->str, &sb) != FAILURE) { if (VCWD_STAT(param->str, &sb) != FAILURE) {
if (sb.st_mode & (S_IFREG|S_IFLNK)) { if (sb.st_mode & (S_IFREG|S_IFLNK)) {
@ -1390,7 +1390,7 @@ PHPDBG_COMMAND(dl) /* {{{ */
PHPDBG_COMMAND(source) /* {{{ */ PHPDBG_COMMAND(source) /* {{{ */
{ {
zend_stat_t sb; zend_stat_t sb = {0};
if (VCWD_STAT(param->str, &sb) != -1) { if (VCWD_STAT(param->str, &sb) != -1) {
phpdbg_try_file_init(param->str, param->len, 0); phpdbg_try_file_init(param->str, param->len, 0);

View file

@ -553,7 +553,7 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
glob_t *pglob; glob_t *pglob;
size_t *limitp; size_t *limitp;
{ {
zend_stat_t sb; zend_stat_t sb = {0};
Char *p, *q; Char *p, *q;
int anymeta; int anymeta;
@ -850,7 +850,7 @@ g_opendir(str, pglob)
static int static int
g_lstat(fn, sb, pglob) g_lstat(fn, sb, pglob)
register Char *fn; register Char *fn;
zend_stat_t *sb; zend_stat_t *sb = {0};
glob_t *pglob; glob_t *pglob;
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
@ -865,7 +865,7 @@ g_lstat(fn, sb, pglob)
static int static int
g_stat(fn, sb, pglob) g_stat(fn, sb, pglob)
register Char *fn; register Char *fn;
zend_stat_t *sb; zend_stat_t *sb = {0};
glob_t *pglob; glob_t *pglob;
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];