From 96ab8a0ef8768e861c9015dd14b87896b59aeb21 Mon Sep 17 00:00:00 2001 From: miod Date: Sat, 12 Jul 2014 16:33:25 +0000 Subject: [PATCH] Make sure the return value of X509_NAME_oneline(, NULL,) is checked against NULL. ok deraadt@ guenther@ jsing@ --- lib/libcrypto/asn1/t_crl.c | 12 +++++++++--- lib/libcrypto/asn1/t_x509.c | 6 ++++-- lib/libssl/src/crypto/asn1/t_crl.c | 12 +++++++++--- lib/libssl/src/crypto/asn1/t_x509.c | 6 ++++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/libcrypto/asn1/t_crl.c b/lib/libcrypto/asn1/t_crl.c index e2f9d8b09ef..67116361a54 100644 --- a/lib/libcrypto/asn1/t_crl.c +++ b/lib/libcrypto/asn1/t_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_crl.c,v 1.15 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: t_crl.c,v 1.16 2014/07/12 16:33:25 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -94,8 +94,11 @@ X509_CRL_print(BIO *out, X509_CRL *x) l = X509_CRL_get_version(x); BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); i = OBJ_obj2nid(x->sig_alg->algorithm); - X509_signature_print(out, x->sig_alg, NULL); + if (X509_signature_print(out, x->sig_alg, NULL) == 0) + goto err; p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); + if (p == NULL) + goto err; BIO_printf(out, "%8sIssuer: %s\n", "", p); free(p); BIO_printf(out, "%8sLast Update: ", ""); @@ -127,8 +130,11 @@ X509_CRL_print(BIO *out, X509_CRL *x) X509V3_extensions_print(out, "CRL entry extensions", r->extensions, 0, 8); } - X509_signature_print(out, x->sig_alg, x->signature); + if (X509_signature_print(out, x->sig_alg, x->signature) == 0) + goto err; return 1; +err: + return 0; } diff --git a/lib/libcrypto/asn1/t_x509.c b/lib/libcrypto/asn1/t_x509.c index e6f0692ccc1..f4872d8b245 100644 --- a/lib/libcrypto/asn1/t_x509.c +++ b/lib/libcrypto/asn1/t_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_x509.c,v 1.24 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: t_x509.c,v 1.25 2014/07/12 16:33:25 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -505,7 +505,9 @@ X509_NAME_print(BIO *bp, X509_NAME *name, int obase) l = 80 - 2 - obase; b = X509_NAME_oneline(name, NULL, 0); - if (!*b) { + if (b == NULL) + return 0; + if (*b == '\0') { free(b); return 1; } diff --git a/lib/libssl/src/crypto/asn1/t_crl.c b/lib/libssl/src/crypto/asn1/t_crl.c index e2f9d8b09ef..67116361a54 100644 --- a/lib/libssl/src/crypto/asn1/t_crl.c +++ b/lib/libssl/src/crypto/asn1/t_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_crl.c,v 1.15 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: t_crl.c,v 1.16 2014/07/12 16:33:25 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -94,8 +94,11 @@ X509_CRL_print(BIO *out, X509_CRL *x) l = X509_CRL_get_version(x); BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); i = OBJ_obj2nid(x->sig_alg->algorithm); - X509_signature_print(out, x->sig_alg, NULL); + if (X509_signature_print(out, x->sig_alg, NULL) == 0) + goto err; p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); + if (p == NULL) + goto err; BIO_printf(out, "%8sIssuer: %s\n", "", p); free(p); BIO_printf(out, "%8sLast Update: ", ""); @@ -127,8 +130,11 @@ X509_CRL_print(BIO *out, X509_CRL *x) X509V3_extensions_print(out, "CRL entry extensions", r->extensions, 0, 8); } - X509_signature_print(out, x->sig_alg, x->signature); + if (X509_signature_print(out, x->sig_alg, x->signature) == 0) + goto err; return 1; +err: + return 0; } diff --git a/lib/libssl/src/crypto/asn1/t_x509.c b/lib/libssl/src/crypto/asn1/t_x509.c index e6f0692ccc1..f4872d8b245 100644 --- a/lib/libssl/src/crypto/asn1/t_x509.c +++ b/lib/libssl/src/crypto/asn1/t_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_x509.c,v 1.24 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: t_x509.c,v 1.25 2014/07/12 16:33:25 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -505,7 +505,9 @@ X509_NAME_print(BIO *bp, X509_NAME *name, int obase) l = 80 - 2 - obase; b = X509_NAME_oneline(name, NULL, 0); - if (!*b) { + if (b == NULL) + return 0; + if (*b == '\0') { free(b); return 1; } -- 2.20.1