]> git.saurik.com Git - apple/libc.git/blobdiff - gen/FreeBSD/readpassphrase.c
Libc-997.1.1.tar.gz
[apple/libc.git] / gen / FreeBSD / readpassphrase.c
index 45ac15f2963fedfe1a1e5978632be204a7811ba3..3bd6a6a5fa63ef2d00ca032bee166e32f9b27776 100644 (file)
@@ -167,11 +167,20 @@ restart:
 char *
 getpass(const char *prompt)
 {
-       static char buf[_PASSWORD_LEN + 1];
+       const size_t bufsiz = _PASSWORD_LEN + 1;
+       static char *buf = NULL;
 
-       if (readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF) == NULL)
+       if (buf == NULL) {
+               buf = malloc(bufsiz);
+               if (buf == NULL) {
+                       return NULL;
+               }
+       }
+
+       if (readpassphrase(prompt, buf, bufsiz, RPP_ECHO_OFF) == NULL) {
                buf[0] = '\0';
-       return(buf);
+       }
+       return buf;
 }
 
 static void handler(int s)