Skip to content

Commit

Permalink
add fixes pointed out by static analysis (#995)
Browse files Browse the repository at this point in the history
This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.
  • Loading branch information
samuel40791765 authored May 10, 2023
1 parent d66b1bd commit a106ff0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crypto/err/err.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ static void err_add_error_vdata(unsigned num, va_list args) {
}
size_t substr_len = strlen(substr);
if (SIZE_MAX - total_size < substr_len) {
va_end(args_copy);
return; // Would overflow.
}
total_size += substr_len;
Expand Down Expand Up @@ -742,6 +743,7 @@ void ERR_add_error_dataf(const char *format, ...) {

va_start(ap, format);
if (OPENSSL_vasprintf_internal(&buf, format, ap, /*system_malloc=*/1) == -1) {
va_end(ap);
return;
}
va_end(ap);
Expand Down
4 changes: 2 additions & 2 deletions ssl/ssl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ static bssl::UniquePtr<EVP_PKEY> GetTestKey() {

static bssl::UniquePtr<SSL_CTX> CreateContextWithTestCertificate(
const SSL_METHOD *method) {
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method()));
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(method));
bssl::UniquePtr<X509> cert = GetTestCertificate();
bssl::UniquePtr<EVP_PKEY> key = GetTestKey();
if (!ctx || !cert || !key ||
Expand All @@ -1629,7 +1629,7 @@ static bssl::UniquePtr<SSL_CTX> CreateContextWithTestCertificate(
static bssl::UniquePtr<SSL_CTX> CreateContextWithCertificate(
const SSL_METHOD *method, bssl::UniquePtr<X509> cert,
bssl::UniquePtr<EVP_PKEY> key) {
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method()));
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(method));
if (!ctx || !cert || !key ||
!SSL_CTX_use_certificate(ctx.get(), cert.get()) ||
!SSL_CTX_use_PrivateKey(ctx.get(), key.get())) {
Expand Down

0 comments on commit a106ff0

Please sign in to comment.