Remove use of sprintf in strutil.cc (#10112)

Co-authored-by: Justin Cohen <justincohen@google.com>
pull/10117/head
strangewiz 3 years ago committed by GitHub
parent d37cbfd448
commit c0fc2e881b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/google/protobuf/stubs/strutil.cc

@ -503,7 +503,7 @@ int CEscapeInternal(const char* src, int src_len, char* dest,
(last_hex_escape && isxdigit(*src)))) {
if (dest_len - used < 4) // need space for 4 letter escape
return -1;
sprintf(dest + used, (use_hex ? "\\x%02x" : "\\%03o"),
snprintf(dest + used, 5, (use_hex ? "\\x%02x" : "\\%03o"),
static_cast<uint8_t>(*src));
is_hex_escape = use_hex;
used += 4;

Loading…
Cancel
Save