summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-05-24 15:23:15 -0400
committerRichard Levitte <levitte@openssl.org>2018-05-26 08:36:42 +0200
commitc8c250333cd254ab3f4d709ebc5ed86a7c065721 (patch)
treeae69c7f88799c452e73b07e7bec459a128fa511a /doc
parentbbbf752a3c8b5a966bcb48fc71a3dc03832e7b27 (diff)
downloadopenssl-new-c8c250333cd254ab3f4d709ebc5ed86a7c065721.tar.gz
Improve the example getpass() implementation to show an error return
Also, modernize the code, so that it isn't trying to store a size_t into an int, and then check the int's sign. :/ Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6271)
Diffstat (limited to 'doc')
-rw-r--r--doc/man3/PEM_read_bio_PrivateKey.pod11
1 files changed, 5 insertions, 6 deletions
diff --git a/doc/man3/PEM_read_bio_PrivateKey.pod b/doc/man3/PEM_read_bio_PrivateKey.pod
index 4fb4d1159a..744a46f81e 100644
--- a/doc/man3/PEM_read_bio_PrivateKey.pod
+++ b/doc/man3/PEM_read_bio_PrivateKey.pod
@@ -346,17 +346,16 @@ Skeleton pass phrase callback:
int pass_cb(char *buf, int size, int rwflag, void *u)
{
- int len;
- char *tmp;
/* We'd probably do something else if 'rwflag' is 1 */
printf("Enter pass phrase for \"%s\"\n", (char *)u);
/* get pass phrase, length 'len' into 'tmp' */
- tmp = "hello";
- len = strlen(tmp);
- if (len <= 0)
- return 0;
+ char *tmp = "hello";
+ if (tmp == NULL) /* An error occurred */
+ return -1;
+
+ size_t len = strlen(tmp);
if (len > size)
len = size;