misc/98111: /etc/groups the parser dies on large groups
Philip M. Gollucci
pgollucci at p6m7g8.com
Mon May 29 15:20:27 PDT 2006
>Number: 98111
>Category: misc
>Synopsis: /etc/groups the parser dies on large groups
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon May 29 22:20:16 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Philip M. Gollucci
>Release: 6.1-RELEASE
>Organization:
P6M7G8 Consulting
>Environment:
FreeBSD minotaur.apache.org 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Thu May 11 11:50:25 PDT 2006 root at minotaur.apache.org:/usr/obj/usr/src/sys/SMP-turbo i38
>Description:
in /etc/groups ... the Apache Software Foundation(ASF) has some large groups
where the parser just craps out. They been successfully using the below patch for at least 1.5 years in 5.3-R,5.4-R, and 6.1-R.
This patch was written by Justin Erenkrantz <justin at erenkrantz.com>.
>How-To-Repeat:
cat /etc/groups
g:*:1010:a,b,c,d,e,f,g,h,i,j,k,l.m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,g
g,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz,aaa,bbb,ccc,ddd,eee,f
ff,ggg,hhh,iii,jjj,kkk,lll,mmm,nnn,ooo,ppp,qqq,rrr,sss,ttt,uuu,vvv,www,xxx,yyy,z
zz,aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii,jjjj,kkkk,llll,mmmm,nnnn,oooo,pp
pp,qqqq,rrrr,ssss,tttt,uuuu,vvvv,wwww,xxxx,yyyy,zzzz,aaaaa,bbbbb,ccccc,ddddd,eee
ee,fffff,ggggg,hhhhh,iiiii,jjjjj,kkkkk,iiiii,lllll,mmmmm,nnnnn,ooooo,ppppp,qqqqq
,rrrrr,sssss,ttttt,uuuuu,vvvvv,wwwww,xxxxx,yyyyy,zzzzz,pgollucci
id pgollucci
uid=1001(pgollucci) gid=0(wheel) groups=0(wheel)
should have said
uid=1001(pgollucci) gid=0(wheel) groups=0(wheel), 1010(g)
pgollucci:*:1001:0::0:0:Philip M. Gollucci:/home/pgollucci:/bin/tcsh
>Fix:
--- lib/libc/gen/getgrent.c.bak Tue Jun 28 09:34:10 2005
+++ lib/libc/gen/getgrent.c Tue Jun 28 10:21:08 2005
@@ -446,6 +446,7 @@
char *buffer;
size_t bufsize, linesize;
int rv, stayopen, *errnop;
+ fpos_t pos;
name = NULL;
gid = (gid_t)-1;
@@ -481,6 +482,7 @@
stayopen = st->stayopen;
}
rv = NS_NOTFOUND;
+ fgetpos(st->fp, &pos);
while ((line = fgetln(st->fp, &linesize)) != NULL) {
if (line[linesize-1] == '\n')
linesize--;
@@ -502,11 +504,15 @@
&buffer[linesize + 1], bufsize - linesize - 1, errnop);
if (rv & NS_TERMINATE)
break;
+ fgetpos(st->fp, &pos);
}
if (!stayopen && st->fp != NULL) {
fclose(st->fp);
st->fp = NULL;
}
+ if (st->fp != NULL && rv == NS_RETURN && *errnop == ERANGE) {
+ fsetpos(st->fp, &pos);
+ }
if (rv == NS_SUCCESS && retval != NULL)
*(struct group **)retval = grp;
return (rv);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list