summaryrefslogtreecommitdiffstats
path: root/engines
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2013-12-09 22:03:34 +0100
committerKurt Roeckx <kurt@roeckx.be>2014-12-10 18:35:18 +0100
commit5b17b79a895bb9eace11d4596acadaa2ed69cf2d (patch)
treeb72dc1b0a2cdc9e0b1ce4f05fb39dba0fd5c4603 /engines
parent3a7581bf5ae3579e506b18f4b36c266c84890450 (diff)
capi_ctrl, capi_vtrace: check for NULL after allocating and free it
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'engines')
-rw-r--r--engines/e_capi.c11
-rw-r--r--engines/e_capi_err.c4
-rw-r--r--engines/e_capi_err.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/engines/e_capi.c b/engines/e_capi.c
index 87a10dd4fc..8a19ed05c7 100644
--- a/engines/e_capi.c
+++ b/engines/e_capi.c
@@ -340,6 +340,11 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
}
ctx = ENGINE_get_ex_data(e, capi_idx);
out = BIO_new_fp(stdout, BIO_NOCLOSE);
+ if (out == NULL)
+ {
+ CAPIerr(CAPI_F_CAPI_CTRL, CAPI_R_FILE_OPEN_ERROR);
+ return 0;
+ }
switch (cmd)
{
case CAPI_CMD_LIST_CSPS:
@@ -406,6 +411,7 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
if (i < 1 || i > 3)
{
CAPIerr(CAPI_F_CAPI_CTRL, CAPI_R_INVALID_LOOKUP_METHOD);
+ BIO_free(out);
return 0;
}
ctx->lookup_method = i;
@@ -1081,6 +1087,11 @@ static void capi_vtrace(CAPI_CTX *ctx, int level, char *format, va_list argptr)
if (!ctx || (ctx->debug_level < level) || (!ctx->debug_file))
return;
out = BIO_new_file(ctx->debug_file, "a+");
+ if (out == NULL)
+ {
+ CAPIerr(CAPI_F_CAPI_VTRACE, CAPI_R_FILE_OPEN_ERROR);
+ return;
+ }
BIO_vprintf(out, format, argptr);
BIO_free(out);
}
diff --git a/engines/e_capi_err.c b/engines/e_capi_err.c
index eaaefb261e..a36ada3156 100644
--- a/engines/e_capi_err.c
+++ b/engines/e_capi_err.c
@@ -1,6 +1,6 @@
/* e_capi_err.c */
/* ====================================================================
- * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved.
+ * Copyright (c) 1999-2014 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -86,6 +86,7 @@ static ERR_STRING_DATA CAPI_str_functs[]=
{ERR_FUNC(CAPI_F_CAPI_RSA_PRIV_DEC), "CAPI_RSA_PRIV_DEC"},
{ERR_FUNC(CAPI_F_CAPI_RSA_PRIV_ENC), "CAPI_RSA_PRIV_ENC"},
{ERR_FUNC(CAPI_F_CAPI_RSA_SIGN), "CAPI_RSA_SIGN"},
+{ERR_FUNC(CAPI_F_CAPI_VTRACE), "CAPI_VTRACE"},
{ERR_FUNC(CAPI_F_CERT_SELECT_DIALOG), "CERT_SELECT_DIALOG"},
{ERR_FUNC(CAPI_F_CLIENT_CERT_SELECT), "CLIENT_CERT_SELECT"},
{ERR_FUNC(CAPI_F_WIDE_TO_ASC), "WIDE_TO_ASC"},
@@ -109,6 +110,7 @@ static ERR_STRING_DATA CAPI_str_reasons[]=
{ERR_REASON(CAPI_R_ERROR_GETTING_KEY_PROVIDER_INFO),"error getting key provider info"},
{ERR_REASON(CAPI_R_ERROR_OPENING_STORE) ,"error opening store"},
{ERR_REASON(CAPI_R_ERROR_SIGNING_HASH) ,"error signing hash"},
+{ERR_REASON(CAPI_R_FILE_OPEN_ERROR) ,"file open error"},
{ERR_REASON(CAPI_R_FUNCTION_NOT_SUPPORTED),"function not supported"},
{ERR_REASON(CAPI_R_GETUSERKEY_ERROR) ,"getuserkey error"},
{ERR_REASON(CAPI_R_INVALID_DIGEST_LENGTH),"invalid digest length"},
diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h
index efa7001038..1844bf073b 100644
--- a/engines/e_capi_err.h
+++ b/engines/e_capi_err.h
@@ -87,6 +87,7 @@ static void ERR_CAPI_error(int function, int reason, char *file, int line);
#define CAPI_F_CAPI_RSA_PRIV_DEC 110
#define CAPI_F_CAPI_RSA_PRIV_ENC 111
#define CAPI_F_CAPI_RSA_SIGN 112
+#define CAPI_F_CAPI_VTRACE 118
#define CAPI_F_CERT_SELECT_DIALOG 117
#define CAPI_F_CLIENT_CERT_SELECT 116
#define CAPI_F_WIDE_TO_ASC 113
@@ -107,6 +108,7 @@ static void ERR_CAPI_error(int function, int reason, char *file, int line);
#define CAPI_R_ERROR_GETTING_KEY_PROVIDER_INFO 109
#define CAPI_R_ERROR_OPENING_STORE 110
#define CAPI_R_ERROR_SIGNING_HASH 111
+#define CAPI_R_FILE_OPEN_ERROR 128
#define CAPI_R_FUNCTION_NOT_SUPPORTED 112
#define CAPI_R_GETUSERKEY_ERROR 113
#define CAPI_R_INVALID_DIGEST_LENGTH 124