]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
doc: Refactored the example in crypto.pod
authoryangyangtiantianlonglong <yangtianlong1224@163.com>
Wed, 16 Feb 2022 15:33:17 +0000 (23:33 +0800)
committerDr. Matthias St. Pierre <matthias.st.pierre@ncp-e.com>
Sun, 20 Feb 2022 11:51:52 +0000 (12:51 +0100)
Added return value and error code in the sample

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17721)

doc/man7/crypto.pod

index 33a321ef6051c19a3a9083eb2d8b4fffa52cfd49..c3e1664be41455a72be16c3150d3e8aafe485996 100644 (file)
@@ -380,6 +380,7 @@ encryption/decryption, signatures, message authentication codes, etc.
  #include <stdio.h>
  #include <openssl/evp.h>
  #include <openssl/bio.h>
+ #include <openssl/err.h>
 
  int main(void)
  {
@@ -390,6 +391,7 @@ encryption/decryption, signatures, message authentication codes, etc.
      };
      unsigned int len = 0;
      unsigned char *outdigest = NULL;
+     int ret = 1;
 
      /* Create a context for the digest operation */
      ctx = EVP_MD_CTX_new();
@@ -430,11 +432,16 @@ encryption/decryption, signatures, message authentication codes, etc.
      /* Print out the digest result */
      BIO_dump_fp(stdout, outdigest, len);
 
+     ret = 0;
+
   err:
      /* Clean up all the resources we allocated */
      OPENSSL_free(outdigest);
      EVP_MD_free(sha256);
      EVP_MD_CTX_free(ctx);
+     if (ret != 0)
+        ERR_print_errors_fp(stderr);
+     return ret;
  }
 
 =head1 CONFIGURATION