This commit is contained in:
parent
92e340f462
commit
e24e2eb78b
1 changed files with 15 additions and 3 deletions
|
|
@ -104,7 +104,6 @@ clicon_file_dirent(const char *dir,
|
|||
DIR *dirp;
|
||||
int res;
|
||||
int nent;
|
||||
int direntStructSize;
|
||||
regex_t re;
|
||||
char errbuf[128];
|
||||
char filename[MAXPATHLEN];
|
||||
|
|
@ -112,8 +111,11 @@ clicon_file_dirent(const char *dir,
|
|||
struct dirent *dent;
|
||||
struct dirent *tmp;
|
||||
struct dirent *new = NULL;
|
||||
struct dirent *dvecp = NULL;
|
||||
#if 0 /* revert of https://github.com/clicon/clixon/pull/238 */
|
||||
int direntStructSize;
|
||||
#endif
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
*ent = NULL;
|
||||
nent = 0;
|
||||
if (regexp && (res = regcomp(&re, regexp, REG_EXTENDED)) != 0) {
|
||||
|
|
@ -145,13 +147,23 @@ clicon_file_dirent(const char *dir,
|
|||
if ((type & st.st_mode) == 0)
|
||||
continue;
|
||||
}
|
||||
#if 0 /* revert of https://github.com/clicon/clixon/pull/238 */
|
||||
direntStructSize = offsetof(struct dirent, d_name) + strlen(dent->d_name) + 1;
|
||||
clicon_debug(1, "%s %u %u %lu", __FUNCTION__, nent, direntStructSize, sizeof(struct dirent));
|
||||
if ((tmp = realloc(new, (nent+1)*direntStructSize)) == NULL) {
|
||||
#else
|
||||
if ((tmp = realloc(new, (nent+1)*sizeof(struct dirent))) == NULL) {
|
||||
#endif
|
||||
clicon_err(OE_UNIX, errno, "realloc");
|
||||
goto quit;
|
||||
}
|
||||
new = tmp;
|
||||
memcpy(&new[nent], dent, direntStructSize);
|
||||
#if 0 /* revert of https://github.com/clicon/clixon/pull/238 */
|
||||
clicon_debug(1, "%s memcpy(%p %p %u", __FUNCTION__, &new[nent], dent, direntStructSize);
|
||||
memcpy(&new[nent], dent, direntStructSize); /* XXX Invalid write of size 8 */
|
||||
#else
|
||||
memcpy(&new[nent], dent, sizeof(*dent));
|
||||
#endif
|
||||
nent++;
|
||||
|
||||
} /* while */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue