Rename a number of BUF_* functions to OPENSSL_*.
Upstream did this in 7644a9aef8932ed4d1c3f25ed776c997702982be, so align
with them. Add the new OPENSSL_* names and switch all callers witihn the
library to match. Keep the old BUF_* names around for compatibility.
Note there were two functions where we already had an OPENSSL_* version:
OPENSSL_strdup and OPENSSL_strnlen. The former now gains a NULL check to
align with BUF_strdup. The latter gets deduplicated; we had two
implementations.
Change-Id: Ia1cd4527a752fcd62e142ed1e1d7768d323279ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38425
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/ssl/d1_both.cc b/ssl/d1_both.cc
index 5a24fb2..2b652d1 100644
--- a/ssl/d1_both.cc
+++ b/ssl/d1_both.cc
@@ -117,7 +117,6 @@
#include <limits.h>
#include <string.h>
-#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/mem.h>
diff --git a/ssl/d1_pkt.cc b/ssl/d1_pkt.cc
index dfb8a67..b9b0ef9 100644
--- a/ssl/d1_pkt.cc
+++ b/ssl/d1_pkt.cc
@@ -115,7 +115,6 @@
#include <string.h>
#include <openssl/bio.h>
-#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/mem.h>
#include <openssl/evp.h>
diff --git a/ssl/dtls_method.cc b/ssl/dtls_method.cc
index d49687f..0ce7c1f 100644
--- a/ssl/dtls_method.cc
+++ b/ssl/dtls_method.cc
@@ -59,7 +59,6 @@
#include <assert.h>
#include <string.h>
-#include <openssl/buf.h>
#include <openssl/err.h>
#include "../crypto/internal.h"
diff --git a/ssl/handshake_client.cc b/ssl/handshake_client.cc
index 8be9f6b..23f48c1 100644
--- a/ssl/handshake_client.cc
+++ b/ssl/handshake_client.cc
@@ -157,7 +157,6 @@
#include <openssl/aead.h>
#include <openssl/bn.h>
-#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/ec_key.h>
#include <openssl/ecdsa.h>
@@ -1291,7 +1290,7 @@
}
assert(psk_len <= PSK_MAX_PSK_LEN);
- hs->new_session->psk_identity.reset(BUF_strdup(identity));
+ hs->new_session->psk_identity.reset(OPENSSL_strdup(identity));
if (hs->new_session->psk_identity == nullptr) {
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
return ssl_hs_error;
diff --git a/ssl/handshake_server.cc b/ssl/handshake_server.cc
index 36aa560..c7d7fb6 100644
--- a/ssl/handshake_server.cc
+++ b/ssl/handshake_server.cc
@@ -152,7 +152,6 @@
#include <string.h>
#include <openssl/bn.h>
-#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/cipher.h>
#include <openssl/ec.h>
diff --git a/ssl/s3_lib.cc b/ssl/s3_lib.cc
index d7f8a85..f1f0ec7 100644
--- a/ssl/s3_lib.cc
+++ b/ssl/s3_lib.cc
@@ -151,7 +151,6 @@
#include <assert.h>
#include <string.h>
-#include <openssl/buf.h>
#include <openssl/digest.h>
#include <openssl/err.h>
#include <openssl/md5.h>
diff --git a/ssl/s3_pkt.cc b/ssl/s3_pkt.cc
index a54bb00..2fcc2a5 100644
--- a/ssl/s3_pkt.cc
+++ b/ssl/s3_pkt.cc
@@ -112,7 +112,6 @@
#include <limits.h>
#include <string.h>
-#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/mem.h>
diff --git a/ssl/ssl_asn1.cc b/ssl/ssl_asn1.cc
index 3fd7fb6..ea02cf4 100644
--- a/ssl/ssl_asn1.cc
+++ b/ssl/ssl_asn1.cc
@@ -87,7 +87,6 @@
#include <utility>
-#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
@@ -758,7 +757,7 @@
static const char kNotResumableSession[] = "NOT RESUMABLE";
*out_len = strlen(kNotResumableSession);
- *out_data = (uint8_t *)BUF_memdup(kNotResumableSession, *out_len);
+ *out_data = (uint8_t *)OPENSSL_memdup(kNotResumableSession, *out_len);
if (*out_data == NULL) {
return 0;
}
diff --git a/ssl/ssl_cert.cc b/ssl/ssl_cert.cc
index b565a35..4f80382 100644
--- a/ssl/ssl_cert.cc
+++ b/ssl/ssl_cert.cc
@@ -121,7 +121,6 @@
#include <utility>
#include <openssl/bn.h>
-#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/ec_key.h>
#include <openssl/err.h>
diff --git a/ssl/ssl_cipher.cc b/ssl/ssl_cipher.cc
index 30037f6..c421292 100644
--- a/ssl/ssl_cipher.cc
+++ b/ssl/ssl_cipher.cc
@@ -143,7 +143,6 @@
#include <assert.h>
#include <string.h>
-#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/md5.h>
#include <openssl/mem.h>
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc
index 703c2bc..a53a5e3 100644
--- a/ssl/ssl_lib.cc
+++ b/ssl/ssl_lib.cc
@@ -699,7 +699,7 @@
if (ctx->psk_identity_hint) {
ssl->config->psk_identity_hint.reset(
- BUF_strdup(ctx->psk_identity_hint.get()));
+ OPENSSL_strdup(ctx->psk_identity_hint.get()));
if (ssl->config->psk_identity_hint == nullptr) {
return nullptr;
}
@@ -2129,7 +2129,7 @@
OPENSSL_PUT_ERROR(SSL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
return 0;
}
- ssl->hostname.reset(BUF_strdup(name));
+ ssl->hostname.reset(OPENSSL_strdup(name));
if (ssl->hostname == nullptr) {
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
return 0;
@@ -2580,7 +2580,7 @@
// ECDHE_PSK can only spell empty hint. Having different capabilities is odd,
// so we interpret empty and missing as identical.
if (identity_hint != NULL && identity_hint[0] != '\0') {
- out->reset(BUF_strdup(identity_hint));
+ out->reset(OPENSSL_strdup(identity_hint));
if (*out == nullptr) {
return 0;
}
diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc
index bb04b1a..77d3f4c 100644
--- a/ssl/ssl_session.cc
+++ b/ssl/ssl_session.cc
@@ -208,7 +208,8 @@
// Copy authentication state.
if (session->psk_identity != nullptr) {
- new_session->psk_identity.reset(BUF_strdup(session->psk_identity.get()));
+ new_session->psk_identity.reset(
+ OPENSSL_strdup(session->psk_identity.get()));
if (new_session->psk_identity == nullptr) {
return nullptr;
}
diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc
index 9bd389b..61de136 100644
--- a/ssl/test/bssl_shim.cc
+++ b/ssl/test/bssl_shim.cc
@@ -39,7 +39,6 @@
#include <openssl/aead.h>
#include <openssl/bio.h>
-#include <openssl/buf.h>
#include <openssl/bytestring.h>
#include <openssl/cipher.h>
#include <openssl/crypto.h>
diff --git a/ssl/test/test_config.cc b/ssl/test/test_config.cc
index 6313673..23de5e9 100644
--- a/ssl/test/test_config.cc
+++ b/ssl/test/test_config.cc
@@ -1361,7 +1361,7 @@
return 0;
}
- BUF_strlcpy(out_identity, config->psk_identity.c_str(), max_identity_len);
+ OPENSSL_strlcpy(out_identity, config->psk_identity.c_str(), max_identity_len);
OPENSSL_memcpy(out_psk, config->psk.data(), config->psk.size());
return config->psk.size();
}
diff --git a/ssl/tls_method.cc b/ssl/tls_method.cc
index 95fac4d..a642e75 100644
--- a/ssl/tls_method.cc
+++ b/ssl/tls_method.cc
@@ -59,7 +59,7 @@
#include <assert.h>
#include <string.h>
-#include <openssl/buf.h>
+#include <openssl/err.h>
#include "../crypto/internal.h"
#include "internal.h"