Make sure the return value of X509_NAME_oneline(, NULL,) is checked against
authormiod <miod@openbsd.org>
Sat, 12 Jul 2014 16:33:25 +0000 (16:33 +0000)
committermiod <miod@openbsd.org>
Sat, 12 Jul 2014 16:33:25 +0000 (16:33 +0000)
NULL.
ok deraadt@ guenther@ jsing@

lib/libcrypto/asn1/t_crl.c
lib/libcrypto/asn1/t_x509.c
lib/libssl/src/crypto/asn1/t_crl.c
lib/libssl/src/crypto/asn1/t_x509.c

index e2f9d8b..6711636 100644 (file)
@@ -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;
 }
index e6f0692..f4872d8 100644 (file)
@@ -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;
        }
index e2f9d8b..6711636 100644 (file)
@@ -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;
 }
index e6f0692..f4872d8 100644 (file)
@@ -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;
        }