Replace deprecated version of absl::HexStringToBytes in test programs and remaining quic/ tests

Replaces the deprecated version of absl::HexStringToBytes that returns std::string with the version that returns bool and populates a passed in std::string. This CL isn't expected to change the behavior of any code used in production.

This allows the Chrome build of QUICHE to build without the `-Wno-deprecated-declarations` clang flag.

PiperOrigin-RevId: 617342915
diff --git a/quiche/quic/core/crypto/web_transport_fingerprint_proof_verifier.cc b/quiche/quic/core/crypto/web_transport_fingerprint_proof_verifier.cc
index 167e4ef..fc8cffd 100644
--- a/quiche/quic/core/crypto/web_transport_fingerprint_proof_verifier.cc
+++ b/quiche/quic/core/crypto/web_transport_fingerprint_proof_verifier.cc
@@ -6,6 +6,8 @@
 
 #include <cstdint>
 #include <memory>
+#include <string>
+#include <utility>
 
 #include "absl/strings/escaping.h"
 #include "absl/strings/match.h"
@@ -18,6 +20,7 @@
 #include "quiche/quic/core/quic_types.h"
 #include "quiche/quic/core/quic_utils.h"
 #include "quiche/quic/platform/api/quic_bug_tracker.h"
+#include "quiche/quic/platform/api/quic_logging.h"
 #include "quiche/common/quiche_text_utils.h"
 
 namespace quic {
@@ -83,8 +86,13 @@
 
   std::string normalized =
       absl::StrReplaceAll(fingerprint.fingerprint, {{":", ""}});
-  hashes_.push_back(WebTransportHash{fingerprint.algorithm,
-                                     absl::HexStringToBytes(normalized)});
+  std::string normalized_bytes;
+  if (!absl::HexStringToBytes(normalized, &normalized_bytes)) {
+    QUIC_DLOG(WARNING) << "Fingerprint hexadecimal is invalid";
+    return false;
+  }
+  hashes_.push_back(
+      WebTransportHash{fingerprint.algorithm, std::move(normalized_bytes)});
   return true;
 }
 
diff --git a/quiche/quic/masque/masque_client_bin.cc b/quiche/quic/masque/masque_client_bin.cc
index eefd002..06e6ed2 100644
--- a/quiche/quic/masque/masque_client_bin.cc
+++ b/quiche/quic/masque/masque_client_bin.cc
@@ -281,7 +281,12 @@
         QUIC_LOG(ERROR) << "Signature authentication key ID cannot be empty";
         return 1;
       }
-      private_key_seed = absl::HexStringToBytes(signature_auth_param_split[1]);
+      if (!absl::HexStringToBytes(signature_auth_param_split[1],
+                                  &private_key_seed)) {
+        QUIC_LOG(ERROR) << "Signature authentication key hex value is invalid";
+        return 1;
+      }
+
       if (private_key_seed.size() != kEd25519Rfc8032PrivateKeySize) {
         QUIC_LOG(ERROR)
             << "Invalid signature authentication private key length "
diff --git a/quiche/quic/masque/masque_server_backend.cc b/quiche/quic/masque/masque_server_backend.cc
index f4ff2e0..66ca13c 100644
--- a/quiche/quic/masque/masque_server_backend.cc
+++ b/quiche/quic/masque/masque_server_backend.cc
@@ -193,7 +193,10 @@
     quiche::QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]);
     SignatureAuthCredential credential;
     credential.key_id = std::string(kv[0]);
-    std::string public_key = absl::HexStringToBytes(kv[1]);
+    std::string public_key;
+    if (!absl::HexStringToBytes(kv[1], &public_key)) {
+      QUIC_LOG(FATAL) << "Invalid signature auth public key hex " << kv[1];
+    }
     if (public_key.size() != sizeof(credential.public_key)) {
       QUIC_LOG(FATAL) << "Invalid signature auth public key length "
                       << public_key.size();
diff --git a/quiche/quic/tools/crypto_message_printer_bin.cc b/quiche/quic/tools/crypto_message_printer_bin.cc
index eb7393d..82850d9 100644
--- a/quiche/quic/tools/crypto_message_printer_bin.cc
+++ b/quiche/quic/tools/crypto_message_printer_bin.cc
@@ -48,7 +48,11 @@
   quic::CryptoFramer framer;
   framer.set_visitor(&printer);
   framer.set_process_truncated_messages(true);
-  std::string input = absl::HexStringToBytes(messages[0]);
+  std::string input;
+  if (!absl::HexStringToBytes(messages[0], &input)) {
+    cerr << "Invalid hex string provided" << endl;
+    return 1;
+  }
   if (!framer.ProcessInput(input)) {
     return 1;
   }
diff --git a/quiche/quic/tools/quic_packet_printer_bin.cc b/quiche/quic/tools/quic_packet_printer_bin.cc
index 5ed7701..314cc20 100644
--- a/quiche/quic/tools/quic_packet_printer_bin.cc
+++ b/quiche/quic/tools/quic_packet_printer_bin.cc
@@ -270,7 +270,11 @@
     quiche::QuichePrintCommandLineFlagHelp(usage);
     return 1;
   }
-  std::string hex = absl::HexStringToBytes(args[1]);
+  std::string hex;
+  if (!absl::HexStringToBytes(args[1], &hex)) {
+    std::cerr << "Invalid hex string" << std::endl;
+    return 1;
+  }
   quic::ParsedQuicVersionVector versions = quic::AllSupportedVersions();
   // Fake a time since we're not actually generating acks.
   quic::QuicTime start(quic::QuicTime::Zero());
diff --git a/quiche/quic/tools/quic_toy_client.cc b/quiche/quic/tools/quic_toy_client.cc
index 791fdeb..49afc35 100644
--- a/quiche/quic/tools/quic_toy_client.cc
+++ b/quiche/quic/tools/quic_toy_client.cc
@@ -63,6 +63,7 @@
 #include "quiche/quic/tools/fake_proof_verifier.h"
 #include "quiche/quic/tools/quic_url.h"
 #include "quiche/common/platform/api/quiche_command_line_flags.h"
+#include "quiche/common/platform/api/quiche_logging.h"
 #include "quiche/common/quiche_text_utils.h"
 #include "quiche/spdy/core/http2_header_block.h"
 
@@ -367,8 +368,10 @@
       << "The length of --server_connection_id must be even. It is "
       << server_connection_id_hex_string.size() << "-byte long.";
   if (!server_connection_id_hex_string.empty()) {
-    const std::string server_connection_id_bytes =
-        absl::HexStringToBytes(server_connection_id_hex_string);
+    std::string server_connection_id_bytes;
+    QUICHE_CHECK(absl::HexStringToBytes(server_connection_id_hex_string,
+                                        &server_connection_id_bytes))
+        << "Failed to parse --server_connection_id hex string.";
     client->set_server_connection_id_override(QuicConnectionId(
         server_connection_id_bytes.data(), server_connection_id_bytes.size()));
   }
@@ -428,8 +431,9 @@
   if (!quiche::GetQuicheCommandLineFlag(FLAGS_body_hex).empty()) {
     QUICHE_DCHECK(quiche::GetQuicheCommandLineFlag(FLAGS_body).empty())
         << "Only set one of --body and --body_hex.";
-    body = absl::HexStringToBytes(
-        quiche::GetQuicheCommandLineFlag(FLAGS_body_hex));
+    QUICHE_DCHECK(absl::HexStringToBytes(
+        quiche::GetQuicheCommandLineFlag(FLAGS_body_hex), &body))
+        << "Failed to parse --body_hex.";
   }
 
   // Construct a GET or POST request for supplied URL.
@@ -466,10 +470,7 @@
       std::cout << "headers:" << header_block.DebugString();
       if (!quiche::GetQuicheCommandLineFlag(FLAGS_body_hex).empty()) {
         // Print the user provided hex, rather than binary body.
-        std::cout << "body:\n"
-                  << QuicheTextUtils::HexDump(absl::HexStringToBytes(
-                         quiche::GetQuicheCommandLineFlag(FLAGS_body_hex)))
-                  << std::endl;
+        std::cout << "body:\n" << QuicheTextUtils::HexDump(body) << std::endl;
       } else {
         std::cout << "body: " << body << std::endl;
       }