[13110] in Athena Bugs

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

7.7: from (RSAIX patch)

daemon@ATHENA.MIT.EDU (Richard Basch)
Thu Jan 19 20:59:33 1995

Date: Thu, 19 Jan 1995 20:59:18 -0500
To: bugs@MIT.EDU, testers@MIT.EDU, rel-eng@MIT.EDU
From: "Richard Basch" <basch@MIT.EDU>


This is a patch, that I believe will help to solve the problem.

The first patch was removing extraneous code.
The second patch actually zeroes out a byte in the buffer, which might
otherwise not be null-terminated.  (The problem is seen when there are
message lines exceeding the line length, which makes the second patch a
likely fix.)

-Richard


--- from.c	1995/01/20 00:50:26	1.1
+++ from.c	1995/01/20 00:54:24
@@ -583,12 +583,12 @@
       fprintf (stderr, "from: out of memory");
       exit (1);
     }    
-  buf[0] = '\0';
-  buf[winlength] = '\0';
   if (from_field)
     strncpy(buf, from_field, winlength);
   else
     strncpy(buf, "<<unknown sender>>", winlength);
+  buf[winlength] = '\0';
+
   len = strlen(buf);
   if  (len < 30)
     len = 30;
@@ -599,13 +599,12 @@
       fprintf (stderr, "from: out of memory");
       exit (1);
     }    
-  buf1[0] = '\0';
 
   if (winlength - len - 1 < 1)
-    subject_field = NULL;
+    subject_field = "";
 
-  if (subject_field)
-    strncpy(buf1, subject_field, winlength - len - 1);
+  strncpy(buf1, subject_field, winlength - len - 1);
+  buf1[winlength - len] = '\0';
   
   printf("%-30s %s\n", buf, buf1);
 

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