From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 32398 invoked from network); 25 May 1998 21:47:41 -0000 Received: from ellpspace.math.ualberta.ca (michal@129.128.88.19) by mail2.redhat.com with SMTP; 25 May 1998 21:47:41 -0000 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.8/8.8.8) id PAA02261; Mon, 25 May 1998 15:47:39 -0600 From: Michal Jaegermann Message-Id: <199805252147.PAA02261@ellpspace.math.ualberta.ca> Subject: Memory allocation bug in 'who' To: bugs@redhat.com Date: Mon, 25 May 1998 15:47:39 -0600 (MDT) Cc: axp-list@redhat.com Content-Type: text There is a minor bug in 'who' from sh-utils. In fact it does not exist in original sh-utils from GNU and it was introduced by sh-utils-1.16-getutent.patch distributed by Red Hat. The problem is that while reading utmp entries a test when to reallocate was reversed and we do not do that **exactly** only when it is needed. In right circumstances this leads to bizzare errors like "Memory exhausted" or "Segmenation violation" and the like. This correction fixes the problem: --- sh-utils-1.16/src/who.c~ Mon May 25 14:22:24 1998 +++ sh-utils-1.16/src/who.c Mon May 25 14:42:37 1998 @@ -534,7 +534,7 @@ while ((uptr=getutent())) { memcpy(&utmp_contents[n_read], uptr, sizeof(STRUCT_UTMP)); n_read++; - if ( n_read % UTMP_READ_INCR ) + if (0 == ( n_read % UTMP_READ_INCR )) xrealloc(utmp_contents,((n_read / UTMP_READ_INCR)+1)* UTMP_READ_INCR*sizeof(STRUCT_UTMP)); } It should be applied only if "getutent.patch" was used. It will fail for a straight GNU version. Michal michal@harddata.com michal@ellpspace.math.ualberta.ca