Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Memory allocation bug in 'who'
@ 1998-05-25 21:47 Michal Jaegermann
  0 siblings, 0 replies; only message in thread
From: Michal Jaegermann @ 1998-05-25 21:47 UTC (permalink / raw)
  To: bugs; +Cc: axp-list


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-05-25 21:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-05-25 21:47 Memory allocation bug in 'who' Michal Jaegermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox