fred@umcp-cs.UUCP (06/11/84)
The routine ``getgrent()'' as distributed with Berkeley Unix 4.1 has a static array declaration: #define MAXGRP 100 static char *gr_mem[MAXGRP]; This leads to all sorts of problems if the number of members of any group becomes larger than MAXGRP. You must change the value of MAXGRP and recompile the library routine, and all the programs which use it. To solve this problem once and for all, I've modified the routine to call ``malloc()'' to dynamically allocate enough space for the array. Changes to the file ``getgrent.c'' are given in this diff script. The version of the file it applies to begins with the line: /* @(#)getgrent.c 4.1 (Berkeley) 12/21/80 */ +-- (and don't forget to strip off column 1 before running it! ;-) ) V |56a | { | int mem_count; | char *cp; | | for (cp = p, mem_count = 0; *cp; mem_count++) | while (*cp && *cp++ != CM); | | if ((int)(gr_mem = (char **)malloc((int)((mem_count + 1) | * sizeof(char *)))) < 1) | return(NULL); | } | group.gr_mem = gr_mem; |. |54d |46a | if (gr_mem) { | free(gr_mem); | gr_mem = (char **)0; | } |. |29a | | if (gr_mem) { | free(gr_mem); | gr_mem = (char **)0; | } |. |21a | | if (gr_mem) { | free(gr_mem); | gr_mem = (char **)0; | } |. |14c |static char **gr_mem = (char **)0; |. |8d |1a |/* Hacked to allow arbitrary numbers of users in a group: 12-Jan-84 FLB */ | |.