Skip to content

Commit 255c84d

Browse files
authored
Abseil LTS branch, Jan 2026, Patch 1 (#2007)
* Fix sign-extension issue in absl::HexStringToBytes() * Restrict MSVC CRC32 intrinsics to x64.
1 parent d407ef1 commit 255c84d

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
module(
1818
name = "abseil-cpp",
19-
version = "20260107.0",
19+
version = "20260107.1",
2020
compatibility_level = 1,
2121
)
2222

absl/base/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
// LTS releases can be obtained from
119119
// https://github.com/abseil/abseil-cpp/releases.
120120
#define ABSL_LTS_RELEASE_VERSION 20260107
121-
#define ABSL_LTS_RELEASE_PATCH_LEVEL 0
121+
#define ABSL_LTS_RELEASE_PATCH_LEVEL 1
122122

123123
// Helper macro to convert a CPP variable to a string literal.
124124
#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x

absl/hash/internal/hash.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@
104104
#define ABSL_HASH_INTERNAL_CRC32_U32 _mm_crc32_u32
105105
#define ABSL_HASH_INTERNAL_CRC32_U8 _mm_crc32_u8
106106

107-
#elif defined(_MSC_VER) && !defined(__clang__) && defined(__AVX__)
107+
// 32-bit builds with AVX do not have _mm_crc32_u64, so the _M_X64 condition is
108+
// necessary.
109+
#elif defined(_MSC_VER) && !defined(__clang__) && defined(__AVX__) && \
110+
defined(_M_X64)
108111

109112
// MSVC AVX (/arch:AVX) implies SSE 4.2.
110113
#include <intrin.h>

absl/strings/escaping.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ bool Base64UnescapeInternal(const char* absl_nullable src, size_t slen,
827827
}
828828

829829
/* clang-format off */
830-
constexpr std::array<char, 256> kHexValueLenient = {
830+
constexpr std::array<uint8_t, 256> kHexValueLenient = {
831831
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
832832
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
833833
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -846,7 +846,7 @@ constexpr std::array<char, 256> kHexValueLenient = {
846846
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
847847
};
848848

849-
constexpr std::array<signed char, 256> kHexValueStrict = {
849+
constexpr std::array<int8_t, 256> kHexValueStrict = {
850850
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
851851
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
852852
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -874,7 +874,7 @@ void HexStringToBytesInternal(const char* absl_nullable from, T to,
874874
size_t num) {
875875
for (size_t i = 0; i < num; i++) {
876876
to[i] = static_cast<char>(kHexValueLenient[from[i * 2] & 0xFF] << 4) +
877-
(kHexValueLenient[from[i * 2 + 1] & 0xFF]);
877+
static_cast<char>(kHexValueLenient[from[i * 2 + 1] & 0xFF]);
878878
}
879879
}
880880

@@ -992,8 +992,10 @@ bool HexStringToBytes(absl::string_view hex, std::string* absl_nonnull bytes) {
992992
output, num_bytes, [hex](char* buf, size_t buf_size) {
993993
auto hex_p = hex.cbegin();
994994
for (size_t i = 0; i < buf_size; ++i) {
995-
int h1 = absl::kHexValueStrict[static_cast<size_t>(*hex_p++)];
996-
int h2 = absl::kHexValueStrict[static_cast<size_t>(*hex_p++)];
995+
int h1 = absl::kHexValueStrict[static_cast<size_t>(
996+
static_cast<uint8_t>(*hex_p++))];
997+
int h2 = absl::kHexValueStrict[static_cast<size_t>(
998+
static_cast<uint8_t>(*hex_p++))];
997999
if (h1 == -1 || h2 == -1) {
9981000
return size_t{0};
9991001
}

absl/strings/escaping_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ TEST(Escaping, HexStringToBytesBackToHex) {
733733
bytes = "abc";
734734
EXPECT_TRUE(absl::HexStringToBytes("", &bytes));
735735
EXPECT_EQ("", bytes); // Results in empty output.
736+
737+
// Ensure there is no sign extension bug on a signed char.
738+
hex.assign("\xC8" "b", 2);
739+
EXPECT_FALSE(absl::HexStringToBytes(hex, &bytes));
736740
}
737741

738742
TEST(HexAndBack, HexStringToBytes_and_BytesToHexString) {

0 commit comments

Comments
 (0)