]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os: make readdir_r buffers larger
authorSage Weil <sage@inktank.com>
Fri, 23 Aug 2013 18:45:35 +0000 (11:45 -0700)
committerSage Weil <sage@inktank.com>
Mon, 26 Aug 2013 20:01:42 +0000 (13:01 -0700)
PATH_MAX isn't quite big enough.

Backport: dumpling, cuttlefish, bobtail
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 99a2ff7da99f8cf70976f05d4fe7aa28dd7afae5)

src/os/FlatIndex.cc
src/os/LFNIndex.cc

index f4a5ce3ab7dcd9c779c8dd6fa158a78196dcdeb2..db46750e411188fec2612912e32cdeba11c76ba8 100644 (file)
@@ -387,7 +387,8 @@ int FlatIndex::collection_list_partial(const hobject_t &start,
 }
 
 int FlatIndex::collection_list(vector<hobject_t> *ls) {
-  char dir_name[PATH_MAX], buf[PATH_MAX], new_name[PATH_MAX];
+  char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
+  char dir_name[PATH_MAX], new_name[PATH_MAX];
   strncpy(dir_name, base_path.c_str(), sizeof(dir_name));
   dir_name[sizeof(dir_name)-1]='\0';
 
@@ -399,7 +400,7 @@ int FlatIndex::collection_list(vector<hobject_t> *ls) {
   vector< pair<ino_t,hobject_t> > inolist;
 
   struct dirent *de;
-  while (::readdir_r(dir, (struct dirent*)buf, &de) == 0) {
+  while (::readdir_r(dir, (struct dirent *)buf, &de) == 0) {
     if (!de)
       break;
     // parse
index 09d0f02267f8c1e5c032165484ce816b007ac4b1..029e8ad8197e65edfd428c24324d68396fb5b62e 100644 (file)
@@ -378,7 +378,7 @@ int LFNIndex::list_objects(const vector<string> &to_list, int max_objs,
                           long *handle, map<string, hobject_t> *out) {
   string to_list_path = get_full_path_subdir(to_list);
   DIR *dir = ::opendir(to_list_path.c_str());
-  char buf[PATH_MAX];
+  char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
   int r;
   if (!dir) {
     return -errno;
@@ -438,7 +438,7 @@ int LFNIndex::list_subdirs(const vector<string> &to_list,
                                  set<string> *out) {
   string to_list_path = get_full_path_subdir(to_list);
   DIR *dir = ::opendir(to_list_path.c_str());
-  char buf[PATH_MAX];
+  char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
   if (!dir)
     return -errno;