From 0843ed62fafb9c6192255bab5b2e66916cea5b39 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 30 Sep 2016 13:47:30 -0700 Subject: [PATCH] Network delete fix. --- osdep/OSUtils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp index 086bb2691..c652e272e 100644 --- a/osdep/OSUtils.cpp +++ b/osdep/OSUtils.cpp @@ -170,9 +170,11 @@ bool OSUtils::rmDashRf(const char *path) return true; dptr = (struct dirent *)0; for(;;) { - if (readdir_r(d,&de,&dptr)) + if (readdir_r(d,&de,&dptr) != 0) break; - if ((dptr)&&(strcmp(dptr->d_name,".") != 0)&&(strcmp(dptr->d_name,"..") != 0)) { + if (!dptr) + break; + if ((strcmp(dptr->d_name,".") != 0)&&(strcmp(dptr->d_name,"..") != 0)&&(strlen(dptr->d_name) > 0)) { std::string p(path); p.push_back(ZT_PATH_SEPARATOR); p.append(dptr->d_name); @@ -180,7 +182,7 @@ bool OSUtils::rmDashRf(const char *path) if (!rmDashRf(p.c_str())) return false; } - } else break; + } } closedir(d); return (rmdir(path) == 0);