summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-quota.c
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2016-07-07 08:51:08 -0400
committerJeff Darcy <jdarcy@redhat.com>2016-07-18 04:59:42 -0700
commit561746080b0b7154bfb3bdee20d426cf2ef7db17 (patch)
tree0dd0db913055925d7843d85c8066a7c0018a290a /xlators/mgmt/glusterd/src/glusterd-quota.c
parent73b9ede7e115fab245b0f59d18e4d6cc4d297cec (diff)
core: use readdir(3) with glibc, and associated cleanup
Starting with glibc-2.23 (i.e. what's in Fedora 25), readdir_r(3) is marked as deprecated. Specifically the function decl in <dirent.h> has the deprecated attribute, and now warnings are thrown during the compile on Fedora 25 builds. The readdir(_r)(3) man page (on Fedora 25 at least) and World+Dog say that glibc's readdir(3) is, and always has been, MT-SAFE as long as only one thread is accessing the directory object returned by opendir(). World+Dog also says there is a potential buffer overflow in readdir_r(). World+Dog suggests that it is preferable to simply use readdir(). There's an implication that eventually readdir_r(3) will be removed from glibc. POSIX has, apparently deprecated it in the standard, or even removed it entirely. Over and above that, our source near the various uses of readdir(_r)(3) has a few unsafe uses of strcpy()+strcat(). (AFAIK nobody has looked at the readdir(3) implemenation in *BSD to see if the same is true on those platforms, and we can't be sure of MacOS even though we know it's based on *BSD.) Change-Id: I5481f18ba1eebe7ee177895eecc9a80a71b60568 BUG: 1356998 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/14838 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-quota.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 55699cc57a9..0d7113bc1a0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -392,10 +392,11 @@ void
glusterd_stop_all_quota_crawl_service (glusterd_conf_t *priv,
glusterd_volinfo_t *volinfo, int type)
{
- char pid_dir[PATH_MAX] = {0, };
- char pidfile[PATH_MAX] = {0,};
- struct dirent *entry = NULL;
DIR *dir = NULL;
+ struct dirent *entry = NULL;
+ struct dirent scratch[2] = {{0,},};
+ char pid_dir[PATH_MAX] = {0,};
+ char pidfile[PATH_MAX] = {0,};
GLUSTERD_GET_QUOTA_CRAWL_PIDDIR (pid_dir, volinfo, type);
@@ -403,7 +404,7 @@ glusterd_stop_all_quota_crawl_service (glusterd_conf_t *priv,
if (dir == NULL)
return;
- GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
+ GF_FOR_EACH_ENTRY_IN_DIR (entry, dir, scratch);
while (entry) {
snprintf (pidfile, sizeof (pidfile), "%s/%s",
pid_dir, entry->d_name);
@@ -412,7 +413,7 @@ glusterd_stop_all_quota_crawl_service (glusterd_conf_t *priv,
_gf_true);
sys_unlink (pidfile);
- GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
+ GF_FOR_EACH_ENTRY_IN_DIR (entry, dir, scratch);
}
sys_closedir (dir);
}