From 249c30a44ade5e35b88bdba43ed7ad47f540c5ce Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 30 Jul 2007 16:54:31 +0000 Subject: make utent.c, getpass.c use __uc_malloc --- libc/misc/utmp/utent.c | 12 ++++++++---- libc/unistd/getpass.c | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c index daa68d24e..51184f01f 100644 --- a/libc/misc/utmp/utent.c +++ b/libc/misc/utmp/utent.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -36,9 +37,10 @@ __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER); /* Some global crap */ -static int static_fd = -1; -static struct utmp static_utmp; static const char default_file_name[] = _PATH_UTMP; + +static int static_fd = -1; +static struct utmp *static_utmp; static const char *static_ut_name = (const char *) default_file_name; /* This function must be called with the LOCK held */ @@ -89,9 +91,11 @@ static struct utmp *__getutent(int utmp_fd) return NULL; } - if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) == sizeof(struct utmp)) + free(static_utmp); + static_utmp = __uc_malloc(sizeof(*static_utmp)); + if (read(utmp_fd, (char *) static_utmp, sizeof(*static_utmp)) == sizeof(*static_utmp)) { - ret = &static_utmp; + ret = static_utmp; } return ret; diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c index 34dbf355b..9eb28ae18 100644 --- a/libc/unistd/getpass.c +++ b/libc/unistd/getpass.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K) @@ -52,12 +52,16 @@ char * getpass (prompt) const char *prompt; { + static char *buf; + FILE *in, *out; struct termios s, t; int tty_changed; - static char buf[PWD_BUFFER_SIZE]; int nread; + free(buf); + buf = __uc_malloc(PWD_BUFFER_SIZE); + /* Try to write to and read from the terminal if we can. If we can't open the terminal, use stderr and stdin. */ -- cgit v1.2.3