🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #1050

null ptr problem with 18.52 emacsclient.c (SYSVIPC section)

#1050
From: h-three!farside!tony
Date: Fri, 30 Sep 1988 20:49
149 lines
4180 bytes
Hello.

    Machine: 386 5.3

    I stumbled upon the fact there was support for SYSV IPC in emacsclient.c
    and tried turning it on.  It basically worked ok, but there was a problem
    where the path to be edited could have garbage inserted if the path given
    to emacsclient began with a '/'.  The diff below includes the following 
    changes:

    	-- would deref null ptr in cwd if path began w '/'
    	-- now only calls getcwd() once for all names
    	    	SYSV getcwd() spawns one or more sub-processes
    	-- minor changes to printfs ala the BSD section

    General comments:

    	I never saw any suggestion to consider turning on HAS_SYSVIPC in
    	any of the s- or m- files.  Should it be on by default in the 
    	SYSV s- files?

    	emacsclient/server usage is not documented anywhere (even in the src,
    	except in server.el)

    	I find it very useful, now that I [think i] understand it.

    	It would be nice if [on a non-windowing system], emacsclient could
    	"wake up" the emacs process and have it take over the screen once
    	again even if the invoking program wasn't an emacs process.  This 
    	would mean losing the screen contents of the pushed program, but 
    	would be somewhat more general.

--tony	 ...!uunet!h-three!tony	 (919) 549-8334	 h-three  Systems  Corporation
	 h-three!tony@uunet.uu.net		 POB 12557; RTP, NC 27709; USA
						 t. e. bennett


*** emacsclient.c~	Mon Sep 26 08:27:11 1988
--- emacsclient.c	Wed Sep 28 11:43:33 1988
***************
*** 142,148 ****
    int s;
    key_t key;
    struct msgbuf * msgp =
!       (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
    struct msqid_ds * msg_st;
    char *homedir, *getenv (), buf[BUFSIZ];
    char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd;
--- 142,148 ----
    int s;
    key_t key;
    struct msgbuf * msgp =
!       (struct msgbuf *) malloc (sizeof (long) + BUFSIZ);
    struct msqid_ds * msg_st;
    char *homedir, *getenv (), buf[BUFSIZ];
    char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd;
***************
*** 171,199 ****
        exit (1);
      }
  
    msgp->mtext[0] = 0;
    argc--; argv++;
    while (argc)
      {
        if (*argv[0] != '/')
  	{
  	  char *val;
! 	  cwd = gwdirb; *cwd = '\0';
  #ifdef BSD
! 	  val = getwd (gwdirb);
  #else
! 	  val = getcwd (gwdirb, sizeof gwdirb);
  #endif
  
! 	  if (val != 0)
  	    {
! 	      strcat (cwd, "/");
  	    }
! 	  else
! 	    {
! 	      fprintf (stderr, cwd);
! 	      *cwd = '\0';
! 	    }
  	}
  	
        strcat (msgp->mtext, cwd);
--- 171,203 ----
        exit (1);
      }
  
+   cwd = gwdirb;
+   *cwd = '\0';
    msgp->mtext[0] = 0;
    argc--; argv++;
+ 
    while (argc)
      {
        if (*argv[0] != '/')
  	{
  	  char *val;
! 
!     	  if (*cwd == '\0')
!     	  {
  #ifdef BSD
! 	    val = getwd (gwdirb);
  #else
! 	    val = getcwd (gwdirb, sizeof gwdirb);
  #endif
  
! 	    if (val != 0)
! 	      	strcat (cwd, "/");
! 	    else
  	    {
! 	      	fprintf (stderr, cwd);
! 	      	*cwd = '\0';
  	    }
! 	  }
  	}
  	
        strcat (msgp->mtext, cwd);
***************
*** 212,223 ****
    /*
     * Now, wait for an answer
     */
!   printf ("Waiting\n");
  
    msgrcv (s, msgp, BUFSIZ, getpid (), 0);	/* wait for anything back */
    strcpy (buf, msgp->mtext);
  
!   printf ("Got back: %s\n", buf);
    exit (0);
  }
  
--- 216,228 ----
    /*
     * Now, wait for an answer
     */
!   printf ("Waiting for Emacs...");
!   fflush(stdout);
  
    msgrcv (s, msgp, BUFSIZ, getpid (), 0);	/* wait for anything back */
    strcpy (buf, msgp->mtext);
  
!   printf ("\n%s\n", buf);
    exit (0);
  }
Technical Details
Message-ID: <8809302049.AA19762@uunet.UU.NET>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!h-three!farside!tony

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!h-three!farside!tony
From: h-three!farside!tony@UUNET.UU.NET
Newsgroups: gnu.emacs.bug
Subject: null ptr problem with 18.52 emacsclient.c (SYSVIPC section)
Message-ID: <8809302049.AA19762@uunet.UU.NET>
Date: 30 Sep 88 20:49:38 GMT
Sender: news@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 148