X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fgetpass.c;fp=sbr%2Fgetpass.c;h=cca32f621c182afd39877afb387be1c4761aa855;hb=966e60efa721d87e5f1cd475de08c26e3bac967e;hp=6a53b72f06e8db09777fe9cf0e21e68bd1165da8;hpb=bb150a8ccfa50b732eeb47110a1f63d91260728c;p=mmh diff --git a/sbr/getpass.c b/sbr/getpass.c index 6a53b72..cca32f6 100644 --- a/sbr/getpass.c +++ b/sbr/getpass.c @@ -30,11 +30,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $ID$ + * $Id$ */ #include -#include #include #define PASSWORD_LEN 128 @@ -43,18 +42,22 @@ #define TCSANOW 0 #endif -char *getpass(const char *prompt) +char * +getpass(char *prompt) { struct termios oterm, term; - int ch; - char *p, *ttystring, buf[PASSWORD_LEN+1]; + char ch; + char *p, *ttystring, *buf; FILE *fout, *fin; + if(!(buf = (char *)calloc((size_t)(PASSWORD_LEN+1), sizeof(char)))) + adios(NULL, "unable to allocate string storage"); + /* Find if stdin is connect to a terminal. If so, read directly from * the terminal, and turn off echo. Otherwise read from stdin. */ - if((ttystring = ttyname(fileno(stdin))) == NULL) { + if((ttystring = (char *)ttyname(fileno(stdin))) == NULL) { fout = stderr; fin = stdin; } @@ -80,5 +83,5 @@ char *getpass(const char *prompt) (void)fputc('\n', fout); (void)fclose(fin); } - return(buf); + return((char *)buf); }