From 7ef64851b1f0e3770e00aa573bddea587616df45 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Thu, 14 Jan 2016 11:38:24 -0500 Subject: [PATCH] librgw: add missing RGWFileHandle::stat in rgw_mkdir 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 --- src/rgw/rgw_file.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 07962edafe4e..3a7aa0ebe4cb 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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(xxx_bogus.c_str())); +#else + return rgw_fh->write(offset, length+1, bytes_written, tbuf); +#endif } /* -- 2.47.3