Просмотр исходного кода

Update contrib/restricted/abseil-cpp-tstring to 20240116.2
b9bec68338edf6d889e826f149efea190e76ac4a

robot-contrib 11 месяцев назад
Родитель
Сommit
1ef9ef5190

+ 2 - 2
contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/ya.make

@@ -6,9 +6,9 @@ LICENSE(Apache-2.0)
 
 LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
 
-VERSION(20240116.1)
+VERSION(20240116.2)
 
-ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.1.tar.gz)
+ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz)
 
 NO_RUNTIME()
 

+ 1 - 1
contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h

@@ -118,7 +118,7 @@
 // LTS releases can be obtained from
 // https://github.com/abseil/abseil-cpp/releases.
 #define Y_ABSL_LTS_RELEASE_VERSION 20240116
-#define Y_ABSL_LTS_RELEASE_PATCH_LEVEL 1
+#define Y_ABSL_LTS_RELEASE_PATCH_LEVEL 2
 
 // Helper macro to convert a CPP variable to a string literal.
 #define Y_ABSL_INTERNAL_DO_TOKEN_STR(x) #x

+ 2 - 2
contrib/restricted/abseil-cpp-tstring/y_absl/functional/ya.make

@@ -6,9 +6,9 @@ LICENSE(Apache-2.0)
 
 LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
 
-VERSION(20240116.1)
+VERSION(20240116.2)
 
-ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.1.tar.gz)
+ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz)
 
 NO_RUNTIME()
 

+ 2 - 2
contrib/restricted/abseil-cpp-tstring/y_absl/memory/ya.make

@@ -6,9 +6,9 @@ LICENSE(Apache-2.0)
 
 LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
 
-VERSION(20240116.1)
+VERSION(20240116.2)
 
-ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.1.tar.gz)
+ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz)
 
 PEERDIR(
     contrib/restricted/abseil-cpp-tstring/y_absl/meta

+ 2 - 2
contrib/restricted/abseil-cpp-tstring/y_absl/meta/ya.make

@@ -6,9 +6,9 @@ LICENSE(Apache-2.0)
 
 LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
 
-VERSION(20240116.1)
+VERSION(20240116.2)
 
-ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.1.tar.gz)
+ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz)
 
 PEERDIR(
     contrib/restricted/abseil-cpp-tstring/y_absl/base

+ 22 - 4
contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.cc

@@ -362,7 +362,7 @@ TString CEscapeInternal(y_absl::string_view src, bool use_hex,
 }
 
 /* clang-format off */
-constexpr unsigned char c_escaped_len[256] = {
+constexpr unsigned char kCEscapedLen[256] = {
     4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4,  // \t, \n, \r
     4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
     1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,  // ", '
@@ -387,8 +387,23 @@ constexpr unsigned char c_escaped_len[256] = {
 // that UTF-8 bytes are not handled specially.
 inline size_t CEscapedLength(y_absl::string_view src) {
   size_t escaped_len = 0;
-  for (char c : src)
-    escaped_len += c_escaped_len[static_cast<unsigned char>(c)];
+  // The maximum value of kCEscapedLen[x] is 4, so we can escape any string of
+  // length size_t_max/4 without checking for overflow.
+  size_t unchecked_limit =
+      std::min<size_t>(src.size(), std::numeric_limits<size_t>::max() / 4);
+  size_t i = 0;
+  while (i < unchecked_limit) {
+    // Common case: No need to check for overflow.
+    escaped_len += kCEscapedLen[static_cast<unsigned char>(src[i++])];
+  }
+  while (i < src.size()) {
+    // Beyond unchecked_limit we need to check for overflow before adding.
+    size_t char_len = kCEscapedLen[static_cast<unsigned char>(src[i++])];
+    Y_ABSL_INTERNAL_CHECK(
+        escaped_len <= std::numeric_limits<size_t>::max() - char_len,
+        "escaped_len overflow");
+    escaped_len += char_len;
+  }
   return escaped_len;
 }
 
@@ -400,12 +415,15 @@ void CEscapeAndAppendInternal(y_absl::string_view src, TString* dest) {
   }
 
   size_t cur_dest_len = dest->size();
+  Y_ABSL_INTERNAL_CHECK(
+      cur_dest_len <= std::numeric_limits<size_t>::max() - escaped_len,
+      "TString size overflow");
   strings_internal::STLStringResizeUninitialized(dest,
                                                  cur_dest_len + escaped_len);
   char* append_ptr = &(*dest)[cur_dest_len];
 
   for (char c : src) {
-    size_t char_len = c_escaped_len[static_cast<unsigned char>(c)];
+    size_t char_len = kCEscapedLen[static_cast<unsigned char>(c)];
     if (char_len == 1) {
       *append_ptr++ = c;
     } else if (char_len == 2) {

+ 2 - 2
contrib/restricted/abseil-cpp-tstring/y_absl/utility/ya.make

@@ -6,9 +6,9 @@ LICENSE(Apache-2.0)
 
 LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
 
-VERSION(20240116.1)
+VERSION(20240116.2)
 
-ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.1.tar.gz)
+ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz)
 
 NO_RUNTIME()