|
@@ -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 @@ __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER);
|
|
|
|
|
|
|
|
|
|
|
|
-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;
|
|
|
|
|
|
|
|
@@ -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;
|