summaryrefslogtreecommitdiffstats
path: root/crypto/pem
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2007-04-05 16:58:39 +0000
committerBen Laurie <ben@openssl.org>2007-04-05 16:58:39 +0000
commit8bbf6ac01056f6e5bba5fd5950fc0356f31cef5b (patch)
tree41ccf5a9eac887545bad9160f902f1aa58f8ab85 /crypto/pem
parent38e952e8aeb0fa2f6864b0d2bc4fd30db991763c (diff)
Don't dereference NULL argument. Coverity ID 52.
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pem.h1
-rw-r--r--crypto/pem/pem_err.c3
-rw-r--r--crypto/pem/pem_info.c6
3 files changed, 9 insertions, 1 deletions
diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
index 51be12317d..9d3f90e46a 100644
--- a/crypto/pem/pem.h
+++ b/crypto/pem/pem.h
@@ -615,6 +615,7 @@ void ERR_load_PEM_strings(void);
#define PEM_R_BAD_PASSWORD_READ 104
#define PEM_R_BAD_VERSION_NUMBER 117
#define PEM_R_BIO_WRITE_FAILURE 118
+#define PEM_R_CIPHER_IS_NULL 127
#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115
#define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119
#define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120
diff --git a/crypto/pem/pem_err.c b/crypto/pem/pem_err.c
index 3318fab533..d644aeedd4 100644
--- a/crypto/pem/pem_err.c
+++ b/crypto/pem/pem_err.c
@@ -1,6 +1,6 @@
/* crypto/pem/pem_err.c */
/* ====================================================================
- * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
+ * Copyright (c) 1999-2007 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
@@ -123,6 +123,7 @@ static ERR_STRING_DATA PEM_str_reasons[]=
{ERR_REASON(PEM_R_BAD_PASSWORD_READ) ,"bad password read"},
{ERR_REASON(PEM_R_BAD_VERSION_NUMBER) ,"bad version number"},
{ERR_REASON(PEM_R_BIO_WRITE_FAILURE) ,"bio write failure"},
+{ERR_REASON(PEM_R_CIPHER_IS_NULL) ,"cipher is null"},
{ERR_REASON(PEM_R_ERROR_CONVERTING_PRIVATE_KEY),"error converting private key"},
{ERR_REASON(PEM_R_EXPECTING_PRIVATE_KEY_BLOB),"expecting private key blob"},
{ERR_REASON(PEM_R_EXPECTING_PUBLIC_KEY_BLOB),"expecting public key blob"},
diff --git a/crypto/pem/pem_info.c b/crypto/pem/pem_info.c
index 7382b61995..1b2be527ed 100644
--- a/crypto/pem/pem_info.c
+++ b/crypto/pem/pem_info.c
@@ -339,6 +339,12 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
{
if ( (xi->enc_data!=NULL) && (xi->enc_len>0) )
{
+ if (enc == NULL)
+ {
+ PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO,PEM_R_CIPHER_IS_NULL);
+ goto err;
+ }
+
/* copy from weirdo names into more normal things */
iv=xi->enc_cipher.iv;
data=(unsigned char *)xi->enc_data;