Demo of use of errors in applications.
[openssl.git] / apps / ts.c
index d73b4eb5addf81fce577b739b2f93058aaf7ce85..ae7604cc698c63457d565e8e320cc41c5e22a85d 100644 (file)
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -618,7 +618,8 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md,
                        {
                        EVP_DigestUpdate(&md_ctx, buffer, length);
                        }
-               EVP_DigestFinal(&md_ctx, *md_value, NULL);
+               if (!EVP_DigestFinal(&md_ctx, *md_value, NULL))
+                       return 0;
                }
        else
                {
@@ -649,7 +650,7 @@ static ASN1_INTEGER *create_nonce(int bits)
 
        /* Generating random byte sequence. */
        if (len > (int)sizeof(buf)) goto err;
-       if (!RAND_bytes(buf, len)) goto err;
+       if (RAND_bytes(buf, len) <= 0) goto err;
 
        /* Find the first non-zero byte and creating ASN1_INTEGER object. */
        for (i = 0; i < len && !buf[i]; ++i);
@@ -1083,7 +1084,7 @@ static X509_STORE *create_cert_store(char *ca_path, char *ca_file)
        cert_ctx = X509_STORE_new();
 
        /* Setting the callback for certificate chain verification. */
-       X509_STORE_set_verify_cb_func(cert_ctx, verify_cb);
+       X509_STORE_set_verify_cb(cert_ctx, verify_cb);
 
        /* Adding a trusted certificate directory source. */
        if (ca_path)