🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #87531

emacs-19.27/lib-src/b2m.c patch (at last!)

#87531
From: Peter F. Couvares
Date: Wed, 21 Sep 1994 00:07
107 lines
3179 bytes
The patch appended to this message simply fixes the b2m program to use
fgets() instead of gets().

(I also #define'd the constant size of the arrays, since each fgets()
call uses it as an argument, and I wanted to avoid using "256" all
over the place.)

It is relative to the emacs-19.27 source.  I hope it's helpful, though
it sure wasn't much.

Thanks for all your hard work!

-Peter

--
-- pfcouvar@unix.amherst.edu (Peter Couvares)
--

*** b2m.c.orig	Tue Sep 20 18:49:17 1994
--- b2m.c	Tue Sep 20 18:55:09 1994
***************
*** 15,23 ****
   *   Mon Nov 7 15:54:06 PDT 1988
   */
  
- /* Serious bug: This program uses `gets', which is intrinsically
-    unreliable--long lines will cause crashes.
-    Someone should fix this program not to use `gets'.  */
  #include <stdio.h>
  #include <time.h>
  #include <sys/types.h>
--- 15,20 ----
***************
*** 37,45 ****
  #define FALSE (0)
  #endif
  
  int header = FALSE, printing;
  time_t ltoday;
! char from[256], labels[256], data[256], *p, *today;
  
  main (argc, argv)
       int argc;
--- 34,44 ----
  #define FALSE (0)
  #endif
  
+ #define MAX_DATA_LEN 256   /* size for from[], labels[], and data[] arrays */
+ 
  int header = FALSE, printing;
  time_t ltoday;
! char from[MAX_DATA_LEN], labels[MAX_DATA_LEN], data[MAX_DATA_LEN], *p, *today;
  
  main (argc, argv)
       int argc;
***************
*** 58,65 ****
    ltoday = time (0);
    today = ctime (&ltoday);
  
!   /* BUG!  Must not use gets in a reliable program!  */
!   if (gets (data))
      {
        if (strncmp (data, "BABYL OPTIONS:", 14))
  	{
--- 57,63 ----
    ltoday = time (0);
    today = ctime (&ltoday);
  
!   if (fgets (data, MAX_DATA_LEN, stdin))
      {
        if (strncmp (data, "BABYL OPTIONS:", 14))
  	{
***************
*** 74,80 ****
    if (printing)
      puts (data);
  
!   while (gets (data))
      {
  
  #if 0
--- 72,78 ----
    if (printing)
      puts (data);
  
!   while (fgets (data, MAX_DATA_LEN, stdin))
      {
  
  #if 0
***************
*** 94,100 ****
        if (!strcmp (data, "\037\f"))
  	{
  	  /* save labels */
! 	  gets (data);
  	  p = strtok (data, " ,\r\n\t");
  	  strcpy (labels, "X-Babyl-Labels: ");
  
--- 92,98 ----
        if (!strcmp (data, "\037\f"))
  	{
  	  /* save labels */
! 	  fgets (data, MAX_DATA_LEN, stdin);
  	  p = strtok (data, " ,\r\n\t");
  	  strcpy (labels, "X-Babyl-Labels: ");
  
Technical Details
Message-ID: <199409210004.AA02899@amhux3.amherst.edu>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!unix.amherst.edu!pfcouvar

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,73c6b9b089e77d1a,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-09-21 15:48:31 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!unix.amherst.edu!pfcouvar
From: pfcouvar@unix.amherst.edu (Peter F. Couvares)
Newsgroups: gnu.emacs.bug
Subject: emacs-19.27/lib-src/b2m.c patch (at last!)
Date: 20 Sep 1994 20:07:01 -0400
Organization: GNUs Not Usenet
Lines: 111
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <199409210004.AA02899@amhux3.amherst.edu>