[PATCH] doc: Improve example gcry_control usage.
Florian Forster
ff at octo.it
Wed Jul 27 14:09:00 CEST 2016
* doc/gcrypt.texi: Change example code to check return value of
gcry_control(GCRYCTL_INIT_SECMEM, …).
---
doc/gcrypt.texi | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi
index c2c39ad..9486400 100644
--- a/doc/gcrypt.texi
+++ b/doc/gcrypt.texi
@@ -424,7 +424,10 @@ and freed memory, you need to initialize Libgcrypt this way:
/* Allocate a pool of 16k secure memory. This make the secure memory
available and also drops privileges where needed. */
- gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+ if (gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0)) {
+ fputs ("initializing secure memory failed\n", stderr);
+ exit (EXIT_FAILURE);
+ }
@anchor{sample-use-resume-secmem}
/* It is now okay to let Libgcrypt complain when there was/is
@@ -687,7 +690,8 @@ enabling the use of secure memory. It also drops all extra privileges
the process has (i.e. if it is run as setuid (root)). If the argument
@var{nbytes} is 0, secure memory will be disabled. The minimum amount
of secure memory allocated is currently 16384 bytes; you may thus use a
-value of 1 to request that default size.
+value of 1 to request that default size. Returns zero on success and
+non-zero on failure.
@item GCRYCTL_TERM_SECMEM; Arguments: none
This command zeroises the secure memory and destroys the handler. The
--
2.8.0.rc3.226.g39d4020
More information about the Gcrypt-devel
mailing list