Skip to content

Commit 0883c85

Browse files
committed
Check for NULL result from strdup
Per Coverity Scan
1 parent a8d59a9 commit 0883c85

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/interfaces/libpq/fe-secure.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,17 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
875875
{
876876
/* Colon, but not in second character, treat as engine:key */
877877
char *engine_str = strdup(conn->sslkey);
878-
char *engine_colon = strchr(engine_str, ':');
878+
char *engine_colon;
879+
880+
if (engine_str == NULL)
881+
{
882+
printfPQExpBuffer(&conn->errorMessage,
883+
libpq_gettext("out of memory\n"));
884+
return -1;
885+
}
886+
887+
/* cannot return NULL because we already checked before strdup */
888+
engine_colon = strchr(engine_str, ':');
879889

880890
*engine_colon = '\0'; /* engine_str now has engine name */
881891
engine_colon++; /* engine_colon now has key name */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy