From 720e93b3825813e99ce7e3f93a4519b776e18f50 Mon Sep 17 00:00:00 2001 From: galsalomon66 Date: Tue, 14 Mar 2023 02:33:07 +0200 Subject: [PATCH] modify json chunk processing function to handle offset/length as csv-processing Signed-off-by: galsalomon66 --- src/rgw/rgw_s3select.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_s3select.cc b/src/rgw/rgw_s3select.cc index 3a11ddf839c6c..039d8647e2321 100644 --- a/src/rgw/rgw_s3select.cc +++ b/src/rgw/rgw_s3select.cc @@ -818,8 +818,15 @@ int RGWSelectObj_ObjStore_S3::json_processing(bufferlist& bl, off_t ofs, off_t l << " obj-size " << m_object_size_for_processing << dendl; continue; } + + if((ofs + len) > it.length()){ + ldpp_dout(this, 10) << "offset and lenghth may cause invalid read: ofs = " << ofs << " len = " << len << " it.length() = " << it.length() << dendl; + ofs = 0; + len = it.length(); + } + m_aws_response_handler.update_processed_size(len); - status = run_s3select_on_json(m_sql_query.c_str(), &(it)[0], len); + status = run_s3select_on_json(m_sql_query.c_str(), &(it)[0] + ofs, len); if (status<0) { status = -EINVAL; break; @@ -828,8 +835,8 @@ int RGWSelectObj_ObjStore_S3::json_processing(bufferlist& bl, off_t ofs, off_t l break; } i++; - } - } + }//for + }//else if (status>=0 && (m_aws_response_handler.get_processed_size() == uint64_t(m_object_size_for_processing) || m_s3_json_object.is_sql_limit_reached())) { //flush the internal JSON buffer(upon last chunk) -- 2.39.5