From 49d31c2bb7d0e718099cd801cbec3d6f541f76e8 Mon Sep 17 00:00:00 2001 From: Gal Salomon Date: Tue, 30 Jul 2024 19:08:44 +0300 Subject: [PATCH] option for resolution of valgrind:InvalidRead. verifying the length of string Signed-off-by: Gal Salomon --- src/rgw/rgw_s3select.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rgw/rgw_s3select.cc b/src/rgw/rgw_s3select.cc index e2e88dfae3093..d30fac1e457f6 100644 --- a/src/rgw/rgw_s3select.cc +++ b/src/rgw/rgw_s3select.cc @@ -807,6 +807,11 @@ int RGWSelectObj_ObjStore_S3::parquet_processing(bufferlist& bl, off_t ofs, off_ } append_in_callback += it.length(); ldout(s->cct, 10) << "S3select: part " << part_no++ << " it.length() = " << it.length() << dendl; + if ((ofs + len) > it.length()){ + ldpp_dout(this, 10) << "s3select: offset and length may cause invalid read: ofs = " << ofs << " len = " << len << " it.length() = " << it.length() << dendl; + ofs = 0; + len = it.length(); + } requested_buffer.append(&(it)[0]+ofs, len); } ldout(s->cct, 10) << "S3select:append_in_callback = " << append_in_callback << dendl; -- 2.39.5