Commit c8c25033 authored by Nick Mathewson's avatar Nick Mathewson Committed by Richard Levitte
Browse files

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: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6271)
parent bbbf752a
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -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;