X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fgetpass.c;h=a8238fb2b0f36a930f67aea1c18014c2f9a2aed1;hb=09470876aa753a96fa312296ed3c39ba761f3dd2;hp=6a53b72f06e8db09777fe9cf0e21e68bd1165da8;hpb=56bd3c9f2bf7b6061fa302c57250612f852bd92e;p=mmh diff --git a/sbr/getpass.c b/sbr/getpass.c index 6a53b72..a8238fb 100644 --- a/sbr/getpass.c +++ b/sbr/getpass.c @@ -30,12 +30,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $ID$ + * $Id$ */ #include -#include +#include /* for calloc() */ #include +#include /* for ttyname() */ +#include "h/mh.h" /* for adios() */ #define PASSWORD_LEN 128 @@ -43,18 +45,22 @@ #define TCSANOW 0 #endif -char *getpass(const char *prompt) +char * +getpass(const char *prompt) { struct termios oterm, term; int ch; - char *p, *ttystring, buf[PASSWORD_LEN+1]; + 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 +86,5 @@ char *getpass(const char *prompt) (void)fputc('\n', fout); (void)fclose(fin); } - return(buf); + return((char *)buf); }