diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-05-24 15:23:15 -0400 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-06-21 19:10:51 +0200 |
commit | 8a8534620da8e13c8a7ab123ecd7fc0226f999bf (patch) | |
tree | 6576c62b0dfe06ac05af01055de1a1e8318a5743 /doc/crypto | |
parent | df70ef22c88eac65ee84201547084cf8f14d512e (diff) |
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)
(cherry picked from commit c8c250333cd254ab3f4d709ebc5ed86a7c065721)
(cherry picked from commit 50d06d1c7d2682b0042e921a76beb509d7ea68e1)
Diffstat (limited to 'doc/crypto')
-rw-r--r-- | doc/crypto/pem.pod | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/doc/crypto/pem.pod b/doc/crypto/pem.pod index 811a5e532d..de9ecca648 100644 --- a/doc/crypto/pem.pod +++ b/doc/crypto/pem.pod @@ -409,17 +409,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", 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; |