From f13336db42ff9879b191c2a8de6316ca67031cd6 Mon Sep 17 00:00:00 2001 From: myang6 Date: Mon, 29 Jun 2026 17:05:47 -0400 Subject: [PATCH 1/4] HYRAX-2193, identify the area where the code needs to change --- dap/DapUtils.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dap/DapUtils.cc b/dap/DapUtils.cc index 4544fbd5b0..1a31dc413d 100644 --- a/dap/DapUtils.cc +++ b/dap/DapUtils.cc @@ -307,6 +307,12 @@ uint64_t crsaibv_process_variable( } else { // width_ll() returns the number of bytes needed to hold the data +cerr<<"var name: "<name() <length_ll() <type()==dods_array_c && var->var()->type() == dods_str_c) { +auto temp_array = dynamic_cast(var); +cerr<<"string size: "<<(temp_array->get_str()).size() <width_ll(true); response_size += vsize; From d405b5ab2d9e9a604d8fbee973a4fec3187e1f39 Mon Sep 17 00:00:00 2001 From: myang6 Date: Mon, 29 Jun 2026 18:52:18 -0400 Subject: [PATCH 2/4] HYRAX-2193, revise the way to calculate the string array size when calculating the maximum response size. --- dap/DapUtils.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dap/DapUtils.cc b/dap/DapUtils.cc index 1a31dc413d..c60fe23eeb 100644 --- a/dap/DapUtils.cc +++ b/dap/DapUtils.cc @@ -307,13 +307,15 @@ uint64_t crsaibv_process_variable( } else { // width_ll() returns the number of bytes needed to hold the data -cerr<<"var name: "<name() <length_ll() <type()==dods_array_c && var->var()->type() == dods_str_c) { -auto temp_array = dynamic_cast(var); -cerr<<"string size: "<<(temp_array->get_str()).size() <width_ll(true); + // If the data type is string, in C++, sizeof(string) is always 24. So the total size for a string array is + // always 24 x number of elements of this array, which may cause false positive for the server to issue + // an error that the maximum response size is exceeded. To avoid this case, we choose to use the minimal possible string size + // for a C string 2: 1 character and 1 terminator. This is also the case for a real NASA file. + if (var->type()==dods_array_c && var->var()->type() == dods_str_c) + vsize = 2*var->length_ll(); + else + vsize = var->width_ll(true); response_size += vsize; BESDEBUG(MODULE_VERBOSE, prolog << " " << get_dap_decl(var) << "(" << vsize << " bytes)" << endl); From 5933c2500dd8a283edb73258f00aa347af874bdf Mon Sep 17 00:00:00 2001 From: myang6 Date: Tue, 30 Jun 2026 10:17:41 -0400 Subject: [PATCH 3/4] HYTAX-2193, update the unit-test after changing the calculation of string size --- dap/unit-tests/DapUtilsTest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dap/unit-tests/DapUtilsTest.cc b/dap/unit-tests/DapUtilsTest.cc index 6cf419cf0b..4afd71fea4 100644 --- a/dap/unit-tests/DapUtilsTest.cc +++ b/dap/unit-tests/DapUtilsTest.cc @@ -417,7 +417,7 @@ class DapUtilsTest : public CppUnit::TestFixture { stringstream msg; uint64_t response_size = 0; - uint64_t expected_response_size = 1016; + uint64_t expected_response_size = 752; uint64_t max_var_size = 200; std::vector too_big; @@ -433,7 +433,7 @@ class DapUtilsTest : public CppUnit::TestFixture { for(auto entry:too_big){ DBG(cerr << prolog << " " << entry << endl); } - CPPUNIT_ASSERT( too_big.size() == 2 ); + CPPUNIT_ASSERT( too_big.size() == 1 ); } else { CPPUNIT_FAIL("ERROR: No variables were deemed too big!"); From 22dba4f6a6a361f6039eeffe67b43f5ce11d2087 Mon Sep 17 00:00:00 2001 From: myang6 Date: Tue, 30 Jun 2026 13:18:36 -0400 Subject: [PATCH 4/4] HYRAX-2193, remove a sonar cloud code smell. --- dap/DapUtils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dap/DapUtils.cc b/dap/DapUtils.cc index c60fe23eeb..44bbc70afe 100644 --- a/dap/DapUtils.cc +++ b/dap/DapUtils.cc @@ -307,7 +307,7 @@ uint64_t crsaibv_process_variable( } else { // width_ll() returns the number of bytes needed to hold the data - uint64_t vsize = var->width_ll(true); + uint64_t vsize = 0; // If the data type is string, in C++, sizeof(string) is always 24. So the total size for a string array is // always 24 x number of elements of this array, which may cause false positive for the server to issue // an error that the maximum response size is exceeded. To avoid this case, we choose to use the minimal possible string size