diff options
Diffstat (limited to 'login')
-rw-r--r-- | login/getutent.c | 15 | ||||
-rw-r--r-- | login/getutid.c | 15 | ||||
-rw-r--r-- | login/getutline.c | 14 |
3 files changed, 31 insertions, 13 deletions
diff --git a/login/getutent.c b/login/getutent.c index 735cd93..561f17f 100644 --- a/login/getutent.c +++ b/login/getutent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -17,12 +17,12 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <stddef.h> /* For NULL. */ +#include <stdlib.h> #include <utmp.h> /* Local buffer to store the result. */ -static struct utmp buffer; +libc_freeres_ptr (static struct utmp *buffer); struct utmp * @@ -30,7 +30,14 @@ __getutent (void) { struct utmp *result; - if (__getutent_r (&buffer, &result) < 0) + if (buffer == NULL) + { + buffer = (struct utmp *) malloc (sizeof (struct utmp)); + if (buffer == NULL) + return NULL; + } + + if (__getutent_r (buffer, &result) < 0) return NULL; return result; diff --git a/login/getutid.c b/login/getutid.c index beeedb3..3d022e4 100644 --- a/login/getutid.c +++ b/login/getutid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -17,20 +17,25 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <stddef.h> /* For NULL. */ +#include <stdlib.h> #include <utmp.h> /* Local buffer to store the result. */ -static struct utmp buffer; - +libc_freeres_ptr (static struct utmp *buffer); struct utmp * __getutid (const struct utmp *id) { struct utmp *result; - if (__getutid_r (id, &buffer, &result) < 0) + if (buffer == NULL) + { + buffer = (struct utmp *) malloc (sizeof (struct utmp)); + if (buffer == NULL) + return NULL; + } + if (__getutid_r (id, buffer, &result) < 0) return NULL; return result; diff --git a/login/getutline.c b/login/getutline.c index d1704ec..7618064 100644 --- a/login/getutline.c +++ b/login/getutline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -17,12 +17,12 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <stddef.h> /* For NULL. */ +#include <stdlib.h> #include <utmp.h> /* Local buffer to store the result. */ -static struct utmp buffer; +libc_freeres_ptr (static struct utmp *buffer); struct utmp * @@ -30,7 +30,13 @@ __getutline (const struct utmp *line) { struct utmp *result; - if (__getutline_r (line, &buffer, &result) < 0) + if (buffer == NULL) + { + buffer = (struct utmp *) malloc (sizeof (struct utmp)); + if (buffer == NULL) + return NULL; + } + if (__getutline_r (line, buffer, &result) < 0) return NULL; return result; |