]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: add missing RGWFileHandle::stat in rgw_mkdir
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 14 Jan 2016 16:38:24 +0000 (11:38 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:08:00 +0000 (12:08 -0500)
The lack of stat here induced a serious memory corruption, due to
the organization of Ganesha file attributes (and their reliance on
the FSAL to initialize the memory).

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc

index 07962edafe4e5e420b84893892d3c26321e25eaf..3a7aa0ebe4cb3595c862bb7ffb3b1d69a064eef0 100644 (file)
@@ -793,6 +793,7 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
       /* XXX unify timestamps */
       time_t now = time(0);
       rgw_fh->set_times(now);
+      rgw_fh->stat(st);
       struct rgw_file_handle *rfh = rgw_fh->get_fh();
       *fh = rfh;
     } else
@@ -1071,7 +1072,20 @@ int rgw_write(struct rgw_fs *rgw_fs,
   if (! rgw_fh->is_open())
     return -EPERM;
 
-  return rgw_fh->write(offset, length, bytes_written, buffer);
+  char tbuf[256];
+  size_t tlen = std::min(length, 255UL);
+  memset(tbuf, 0, 256);
+  memcpy(tbuf, buffer, tlen);
+  std::cout << __func__ << " " << length << " bytes"
+           << " at offset " << offset
+           << " {{" << tbuf << "}}" << std::endl;
+#if 1 /* XXXX buffer::create_static w/buffer corrupts data  */
+  string xxx_bogus{tbuf};
+  return rgw_fh->write(0, xxx_bogus.size(), bytes_written,
+                      const_cast<char*>(xxx_bogus.c_str()));
+#else
+  return rgw_fh->write(offset, length+1, bytes_written, tbuf);
+#endif
 }
 
 /*