aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/rspamc.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-19 17:09:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-19 17:09:11 +0100
commitac3e68dfb97e069d4d9fe9ad2d3f1917b36dfe19 (patch)
tree00424278c1ca13b73c3f4f6ec28adb253213def8 /src/client/rspamc.c
parent3da37eb2717f5bcc167d158c3fc2433ab2b3d179 (diff)
downloadrspamd-ac3e68dfb97e069d4d9fe9ad2d3f1917b36dfe19.tar.gz
rspamd-ac3e68dfb97e069d4d9fe9ad2d3f1917b36dfe19.zip
[Fix] One more check for readdir...
Diffstat (limited to 'src/client/rspamc.c')
-rw-r--r--src/client/rspamc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index c7068ae8d..7e60885ea 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -1449,7 +1449,7 @@ rspamc_process_dir (struct event_base *ev_base, struct rspamc_command *cmd,
const gchar *name, GQueue *attrs)
{
DIR *d;
- struct dirent *entry, **pentry = NULL;
+ struct dirent *entry, *pentry;
gint cur_req = 0;
gchar fpath[PATH_MAX];
FILE *in;
@@ -1465,24 +1465,24 @@ rspamc_process_dir (struct event_base *ev_base, struct rspamc_command *cmd,
g_assert (len != (gsize)-1);
entry = g_malloc0 (len);
- while (readdir_r (d, entry, pentry) == 0) {
+ while (readdir_r (d, entry, &pentry) == 0 && pentry != NULL) {
if (pentry == NULL) {
break;
}
- if (entry->d_name[0] == '.') {
+ if (pentry->d_name[0] == '.') {
continue;
}
rspamd_snprintf (fpath, sizeof (fpath), "%s%c%s",
name, G_DIR_SEPARATOR,
- entry->d_name);
+ pentry->d_name);
is_reg = FALSE;
is_dir = FALSE;
#if (defined(_DIRENT_HAVE_D_TYPE) || defined(__APPLE__)) && defined(DT_UNKNOWN)
- if (entry->d_type == DT_UNKNOWN) {
+ if (pentry->d_type == DT_UNKNOWN) {
/* Fallback to lstat */
if (lstat (fpath, &st) == -1) {
rspamd_fprintf (stderr, "cannot stat file %s: %s\n",
@@ -1494,10 +1494,10 @@ rspamc_process_dir (struct event_base *ev_base, struct rspamc_command *cmd,
is_reg = S_ISREG (st.st_mode);
}
else {
- if (entry->d_type == DT_REG) {
+ if (pentry->d_type == DT_REG) {
is_reg = TRUE;
}
- else if (entry->d_type == DT_DIR) {
+ else if (pentry->d_type == DT_DIR) {
is_dir = TRUE;
}
}