diff options
Diffstat (limited to 'c/src/exec/libcsupport/src/getgrent.c')
-rw-r--r-- | c/src/exec/libcsupport/src/getgrent.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/c/src/exec/libcsupport/src/getgrent.c b/c/src/exec/libcsupport/src/getgrent.c index b47ece8283..da339718a0 100644 --- a/c/src/exec/libcsupport/src/getgrent.c +++ b/c/src/exec/libcsupport/src/getgrent.c @@ -1,7 +1,14 @@ /* + * POSIX 1003.1b - 9.2.1 - Group Database Access Routines + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * * $Id$ */ + #include <stdio.h> #include <sys/types.h> #include <grp.h> @@ -14,11 +21,20 @@ static struct group gr_group; /* password structure */ static FILE *group_fp; +/* + * The size of these buffers is arbitrary and there is no provision + * to protect any of them from overflowing. The scanf patterns + * need to be changed to prevent overflowing. In addition, + * the limits on these needs to be examined. + */ + static char groupname[8]; static char password[1024]; static char groups[1024]; static char *gr_mem[16] = { } ; +extern void init_etc_passwd_group(void); + int getgrnam_r( const char *name, struct group *grp, @@ -29,6 +45,8 @@ int getgrnam_r( { FILE *fp; + init_etc_passwd_group(); + if ((fp = fopen ("/etc/group", "r")) == NULL) { errno = EINVAL; return -1; @@ -76,6 +94,8 @@ int getgrgid_r( { FILE *fp; + init_etc_passwd_group(); + if ((fp = fopen ("/etc/group", "r")) == NULL) { errno = EINVAL; return -1; @@ -137,6 +157,8 @@ struct group *getgrent( void ) void setgrent () { + init_etc_passwd_group(); + if (group_fp != NULL) fclose (group_fp); |