Last modified: Thursday, July 02, 2026

Patch to avoid segmentation violation in xrwho-1.1

xrwho, X11, SIGSEGV

xrwho is the X11 version of rwho and displays a list of currently logged-in users by host.

This fix addresses a bug that could cause the program to crash due to a segmentation violation on large sites where users frequently log in and out.

xrwho-1.1p1.patch (November 6, 1997)



Only in xrwho.new: Makefile
diff -rc xrwho/xrwho.c xrwho.new/xrwho.c
*** xrwho/xrwho.c	Thu Nov  6 19:13:12 1997
--- xrwho.new/xrwho.c	Thu Nov  6 15:17:10 1997
***************
*** 545,552 ****
  	/* we haven't heard from host for too long so ignore it */
  	return 0;
      }
  
!     return (bytes - 60)/sizeof(struct whoent);	/* number of whoent records */
  }
  
  
--- 545,558 ----
  	/* we haven't heard from host for too long so ignore it */
  	return 0;
      }
+     if (bytes < 0) {
+ #ifdef Debug
+ 	printf("xrwho: can't read %s/%s\n", RWHODIR, filename);
+ #endif
+ 	return 0;
+     }
  
!     return ((bytes == 0) ? 0 : (bytes - 60)/sizeof(struct whoent));	/* number of whoent records */
  }
  
  
***************
*** 637,642 ****
--- 643,651 ----
  	 * scan through the utmp-style array for the host, updating idle times
  	 * and checking whether users are still logged on
  	 */
+ #ifdef Debug
+ 	printf("# of users %d\n", n);
+ #endif
  	for (j = 0; j < n; j++) {
  	    char *name;
  	    int	idle;
***************
*** 847,853 ****
--- 856,865 ----
          if (hui->head != (user_t *)NULL)
              printf("%s (%s), load: %g, wid: %ld\n", hui->host_name,
  		XtIsManaged(hui->title) ? "managed" : "not managed",
+ 		0.01*hui->loadrange, hui->title);
+ 		   /*
  		0.01*hui->loadav, hui->title);
+ 		*/
  
          for (k = hui->head; k != (user_t *)NULL; k = k->next) {
  	   printf("   %s - idle %d %s (%d) wid: %ld\n", k->name, k->idle,

Atsushi NUNOME @ Computer System Laboratory at Kyoto Institute of Technology (nunome@kit.ac.jp)