svn commit: trunk/uClibc/libc: misc/utmp unistd

vda at uclibc.org vda at uclibc.org
Mon Jul 30 16:54:32 UTC 2007


Author: vda
Date: 2007-07-30 09:54:31 -0700 (Mon, 30 Jul 2007)
New Revision: 19345

Log:
make utent.c, getpass.c use __uc_malloc



Modified:
   trunk/uClibc/libc/misc/utmp/utent.c
   trunk/uClibc/libc/unistd/getpass.c


Changeset:
Modified: trunk/uClibc/libc/misc/utmp/utent.c
===================================================================
--- trunk/uClibc/libc/misc/utmp/utent.c	2007-07-30 16:54:07 UTC (rev 19344)
+++ trunk/uClibc/libc/misc/utmp/utent.c	2007-07-30 16:54:31 UTC (rev 19345)
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <malloc.h>
 #include <fcntl.h>
 #include <paths.h>
 #include <errno.h>
@@ -36,9 +37,10 @@
 
 
 /* Some global crap */
+static const char default_file_name[] = _PATH_UTMP;
+
 static int static_fd = -1;
-static struct utmp static_utmp;
-static const char default_file_name[] = _PATH_UTMP;
+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 @@
 	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;

Modified: trunk/uClibc/libc/unistd/getpass.c
===================================================================
--- trunk/uClibc/libc/unistd/getpass.c	2007-07-30 16:54:07 UTC (rev 19344)
+++ trunk/uClibc/libc/unistd/getpass.c	2007-07-30 16:54:31 UTC (rev 19345)
@@ -20,7 +20,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
-#include <string.h>
+#include <malloc.h>
 
 #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
 
@@ -52,12 +52,16 @@
 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.  */
 




More information about the uClibc-cvs mailing list