[2857] in Release_Engineering

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

patch for console...

daemon@ATHENA.MIT.EDU (vanharen@MIT.EDU)
Thu Jun 4 16:31:18 1992

From: vanharen@MIT.EDU
Date: Thu, 4 Jun 92 16:31:03 EDT
To: rel-eng@MIT.EDU

There are a few bugs in the console program, which look similar but are
slightly different.

They can be triggered several ways -- if you are going to do testing, I
would test all the methods described to be sure that the bugs are fixed.
In already tested all the methods described on all major platforms (dec,
vax, rt, rs6000, and sun :-), but I presume you guys do testing as well
before installing...


Method A:
	1) type "console", and you will get a blank console, waiting on
		stdin.
	2) start typing something.  type a few lines, like 3 (something
		less than the number of lines which it could hold before
		scrolling).
	3) triple-click with mouse-button-1 on one of the lines and hold
			- AND/OR -
		quad-click somewhere on the text and hold.
	4) drag mouse past the end of the text.
		(notice how the text un-hilites when you past the
		 end of it -- bug, but not as serious a problem as the
		 next step...)
	5) now let go of the button.  console will leave you a nice
		message about trying to malloc some large negative
		number of bytes...  (on the Sun, you get a nifty core
		file, though...)

Method B:
	1) see step 1, method A.
	2) see step 2, method A.
	3) same as step 3, except let go, instead of hold.
	4) single-click with mouse-button-3 in the white area past the
		end of the text.  dead console.

Method C:
	1) see step 1, method A.
	2) see step 2, method A.
	3) quad-click in the white area past the end of the text.  say
		goodnight, gracie.


(Notice the nifty screw if you try this with your standard console --
 console dies and outputs an error, which dm directs to /dev/console, but
 by that point, there's nothing there to display it...  oh well.)


The problem is bad bounds-checking on the array of text...  the patch
below also fixes a bounds condition which no-one should ever trip
anyway, but I fixed it nonetheless (if you happen to have a blank line
before the first paragraph, and then try to select the first paragraph,
it also selects the first line, but since we timestamp all the lines,
there are no blank lines in the console).

Anyway, here's the patch to fix it (in the right order, this time,
Craig!  :-)
							-C.

==============================================================================
*** /source/athena/athena.bin/dash/TextDisplay.c	Fri May  1 19:48:50 1992
--- ./TextDisplay.c	Thu Jun  4 08:32:30 1992
***************
*** 847,853 ****
--- 847,856 ----
     */
    if (LINE > me->textDisplay.numLines
        &&  me->textDisplay.visLines > me->textDisplay.numLines)
+     {
+       LINE = me->textDisplay.numLines;
        return me->textDisplay.lineStarts[me->textDisplay.numLines];
+     }
  
    /*
     * ...then check if we want to scroll down...
***************
*** 962,968 ****
      }
  
    if (clickTimes == 3)		/* triple-clicks - select by "line" */
!     return me->textDisplay.lineStarts[(find_start) ? line : line + 1];
  
    if (clickTimes == 4)		/* quad-clicks - select by "paragraph" */
      {
--- 965,974 ----
      }
  
    if (clickTimes == 3)		/* triple-clicks - select by "line" */
!     return me->textDisplay.lineStarts[(find_start)
! 				      ? line
! 				      : MIN(me->textDisplay.numLines,
! 					    line + 1)];
  
    if (clickTimes == 4)		/* quad-clicks - select by "paragraph" */
      {
***************
*** 975,988 ****
  	   *  scan backward to the beginning of the "paragraph"
  	   */
  	  for (x = line;
! 	       x > 1;
  	       x--)
  	    {
  	      blankline = True;
  	      for (tmp = me->textDisplay.lineStarts[x];
! 		   blankline && tmp < (me->textDisplay.lineStarts[x+1] - 1);
  		   tmp++)
! 		if (*tmp != ' ' && *tmp != '\t')
  		  blankline = False;
  
  	      if (blankline)
--- 981,996 ----
  	   *  scan backward to the beginning of the "paragraph"
  	   */
  	  for (x = line;
! 	       x >= 0;
  	       x--)
  	    {
  	      blankline = True;
+ 	      if (x < me->textDisplay.numLines)
  		for (tmp = me->textDisplay.lineStarts[x];
! 		     blankline && tmp <= (me->textDisplay.lineStarts[x+1] - 1);
  		     tmp++)
! 		  if (*tmp != ' '  && *tmp != '\t' &&
! 		      *tmp != '\n' && *tmp != '\0')
  		    blankline = False;
  
  	      if (blankline)
***************
*** 1002,1010 ****
  	    {
  	      blankline = True;
  	      for (tmp = me->textDisplay.lineStarts[x];
! 		   blankline && tmp < (me->textDisplay.lineStarts[x+1] - 1);
  		   tmp++)
! 		if (*tmp != ' ' && *tmp != '\t')
  		  blankline = False;
  
  	      if (blankline)
--- 1010,1019 ----
  	    {
  	      blankline = True;
  	      for (tmp = me->textDisplay.lineStarts[x];
! 		   blankline && tmp <= (me->textDisplay.lineStarts[x+1] - 1);
  		   tmp++)
! 		if (*tmp != ' '  && *tmp != '\t' &&
! 		    *tmp != '\n' && *tmp != '\0')
  		  blankline = False;
  
  	      if (blankline)

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