[1785] in testers

home help back first fref pref prev next nref lref last post

Re: rsaix 7.3f discuss breaks on long subject lines

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue Aug 6 19:29:36 1991

Date: Tue, 6 Aug 91 19:29:34 -0400
From: tytso@ATHENA.MIT.EDU (Theodore Ts'o)
To: tompalka@ATHENA.MIT.EDU
Cc: testers@ATHENA.MIT.EDU
In-Reply-To: thomas palka's message of Tue, 6 Aug 91 17:18:42 -0400,
Reply-To: tytso@ATHENA.MIT.EDU

   From: tompalka@ATHENA.MIT.EDU
   Date: Tue, 6 Aug 91 17:18:42 -0400


   Try this:

	[ demonstration of how to coredump the discuss client by listing
	transactions 1960 through 2000 in the ostock meeting omitted.]

It turns out this was a bug that was discovered by Richard in discuss
1.5, but the change never made it back to the SIPB's discuss sources.
Here are patches to edsc/do_misc.c and client/list.c (the problem
affects both edsc and the terminal client).  Basically, the listing code
tries to use strncpy() to insert spaces to line up the columns in the
list of transactions.  Unfortunately, if the number of lines of a
transactions exceeds 1000 lines, one of the fields become too big, and
strncpy gets passed a negative number.  The strncpy() on the Vax and the
RT don't mind, but on the RIOS it coredumps.

							- Ted

*** /tmp/,RCSt1000783	Tue Aug  6 19:23:29 1991
--- edsc/do_misc.c	Tue Aug  6 18:55:03 1991
***************
*** 349,355 ****
  {
  	char newtime[26], nlines[10];
  	char *cp;
! 	int max_len;
  
  	strcpy(newtime, short_time(&t_infop->date_entered));
  	/*
--- 349,355 ----
  {
  	char newtime[26], nlines[10];
  	char *cp;
! 	int len;
  
  	strcpy(newtime, short_time(&t_infop->date_entered));
  	/*
***************
*** 364,371 ****
  			t_infop->current,
  			((t_infop->flags & TRN_FLAG1) != 0) ? 'F' : ' ',
  			((t_infop->flags & TRN_FDELETED) != 0) ? 'D' : ' ');
! 	(void) strncat (buffer, "     ",
! 			MIN (5, 13-strlen (buffer)) - strlen (nlines));
  
  	if (strlen(t_infop->author) > 15)
  		(void) strcpy(&t_infop->author[12], "...");
--- 364,371 ----
  			t_infop->current,
  			((t_infop->flags & TRN_FLAG1) != 0) ? 'F' : ' ',
  			((t_infop->flags & TRN_FDELETED) != 0) ? 'D' : ' ');
! 	if ((len = MIN(5, 13-strlen (buffer)) - strlen (nlines)) > 0)
! 		(void) strncat (buffer, "     ", len);
  
  	if (strlen(t_infop->author) > 15)
  		(void) strcpy(&t_infop->author[12], "...");
***************
*** 372,381 ****
  
  	(void) sprintf (buffer + strlen (buffer), "%s %s %-15s ",
  			nlines, newtime, t_infop->author);
! 	max_len = 79 - strlen (buffer);
  
! 	if (!long_subjects && strlen (t_infop->subject) > max_len)
! 	    (void) strcpy (&t_infop->subject [max_len - 3], "...");
  
  	(void) fprintf (f, "%s%s\n", buffer, t_infop->subject);
  
--- 372,381 ----
  
  	(void) sprintf (buffer + strlen (buffer), "%s %s %-15s ",
  			nlines, newtime, t_infop->author);
! 	len = 79 - strlen (buffer);
  
! 	if (!long_subjects && strlen (t_infop->subject) > len)
! 	    (void) strcpy (&t_infop->subject [len - 3], "...");
  
  	(void) fprintf (f, "%s%s\n", buffer, t_infop->subject);
  
*** /tmp/,RCSt1000788	Tue Aug  6 19:23:49 1991
--- client/list.c	Tue Aug  6 19:18:47 1991
***************
*** 44,50 ****
  {
  	char newtime[26], nlines[10];
  	char *cp,*author;
! 	int max_len;
  
  	if (*codep == NO_ACCESS) {
  	        *codep = 0;
--- 44,50 ----
  {
  	char newtime[26], nlines[10];
  	char *cp,*author;
! 	int len;
  
  	if (*codep == NO_ACCESS) {
  	        *codep = 0;
***************
*** 82,89 ****
  			t_infop->current,
  			((t_infop->flags & TRN_FLAG1) != 0) ? "F" : "",
  			(t_infop->current == dsc_public.current) ? '*' : ' ');
! 	(void) strncat (buffer, "     ",
! 			MIN (5, 13-strlen (buffer)) - strlen (nlines));
  
  	if (strlen(author) > 15)
  		(void) strcpy(&author[12], "...");
--- 82,89 ----
  			t_infop->current,
  			((t_infop->flags & TRN_FLAG1) != 0) ? "F" : "",
  			(t_infop->current == dsc_public.current) ? '*' : ' ');
! 	if ((len = MIN(5, 13-strlen (buffer)) - strlen (nlines)) > 0)
! 		(void) strncat (buffer, "     ", len);
  
  	if (strlen(author) > 15)
  		(void) strcpy(&author[12], "...");
***************
*** 90,99 ****
  
  	(void) sprintf (buffer + strlen (buffer), "%s %s %-15s ",
  			nlines, newtime, author);
! 	max_len = 79 - strlen (buffer);
  
! 	if (!long_subjects && strlen (t_infop->subject) > max_len)
! 	    (void) strcpy (&t_infop->subject [max_len - 3], "...");
  
  	(void) printf ("%s%s\n", buffer, t_infop->subject);
  
--- 90,99 ----
  
  	(void) sprintf (buffer + strlen (buffer), "%s %s %-15s ",
  			nlines, newtime, author);
! 	len = 79 - strlen (buffer);
  
! 	if (!long_subjects && strlen (t_infop->subject) > len)
! 	    (void) strcpy (&t_infop->subject [len - 3], "...");
  
  	(void) printf ("%s%s\n", buffer, t_infop->subject);
  

home help back first fref pref prev next nref lref last post