Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Mar 2017 14:09:13 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r315950 - vendor/tcsh/dist
Message-ID:  <201703251409.v2PE9D7f016807@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sat Mar 25 14:09:12 2017
New Revision: 315950
URL: https://svnweb.freebsd.org/changeset/base/315950

Log:
  Update vendor/tcsh to git b605cb561d
  
  Vendor changes:
  
  1. PR/471: Daiki Ueno: Delay interpreting arginp until we've processed
  our startup files (which can change the NLS environment).
  
  2. Fix type of read in prompt confirmation (eg. rmstar) (David Kaspar).
  
  3. Fix out of bounds read (Brooks Davis)
  (reproduce by starting tcsh and hitting tab at the prompt).
  
  4. Don't play pointer tricks that are undefined in modern c
  (Brooks Davis).

Modified:
  vendor/tcsh/dist/Fixes
  vendor/tcsh/dist/ed.chared.c
  vendor/tcsh/dist/sh.c
  vendor/tcsh/dist/sh.func.c
  vendor/tcsh/dist/tw.init.c

Modified: vendor/tcsh/dist/Fixes
==============================================================================
--- vendor/tcsh/dist/Fixes	Sat Mar 25 13:33:23 2017	(r315949)
+++ vendor/tcsh/dist/Fixes	Sat Mar 25 14:09:12 2017	(r315950)
@@ -1,3 +1,4 @@
+ 22. Fix type of read in prompt confirmation (eg. rmstar) (David Kaspar)
  20. V6.20.00 - 20161124
  19. Don't resize the screen if it did not change size.
  18. V6.19.01 - 20161025

Modified: vendor/tcsh/dist/ed.chared.c
==============================================================================
--- vendor/tcsh/dist/ed.chared.c	Sat Mar 25 13:33:23 2017	(r315949)
+++ vendor/tcsh/dist/ed.chared.c	Sat Mar 25 14:09:12 2017	(r315950)
@@ -750,7 +750,7 @@ c_substitute(void)
     /*
      * If we found a history character, go expand it.
      */
-    if (HIST != '\0' && *p == HIST)
+    if (p >= InputBuf && HIST != '\0' && *p == HIST)
 	nr_exp = c_excl(p);
     else
         nr_exp = 0;

Modified: vendor/tcsh/dist/sh.c
==============================================================================
--- vendor/tcsh/dist/sh.c	Sat Mar 25 13:33:23 2017	(r315949)
+++ vendor/tcsh/dist/sh.c	Sat Mar 25 14:09:12 2017	(r315950)
@@ -248,6 +248,7 @@ main(int argc, char **argv)
     char *tcp, *ttyn;
     int f, reenter;
     char **tempv;
+    const char *targinp = NULL;
     int osetintr;
     struct sigaction oparintr;
 
@@ -937,30 +938,7 @@ main(int argc, char **argv)
 		      *p &= ASCII;
 		  }
 #endif
-		arginp = SAVE(tempv[0]);
-
-		/*
-		 * we put the command into a variable
-		 */
-		if (arginp != NULL)
-		    setv(STRcommand, quote(Strsave(arginp)), VAR_READWRITE);
-
-		/*
-		 * * Give an error on -c arguments that end in * backslash to
-		 * ensure that you don't make * nonportable csh scripts.
-		 */
-		{
-		    int count;
-
-		    cp = Strend(arginp);
-		    count = 0;
-		    while (cp > arginp && *--cp == '\\')
-			++count;
-		    if ((count & 1) != 0) {
-			exiterr = 1;
-			stderror(ERR_ARGC);
-		    }
-		}
+		targinp = tempv[0];
 		prompt = 0;
 		nofile = 1;
 		break;
@@ -1205,7 +1183,7 @@ main(int argc, char **argv)
 	    sigset_interrupting(SIGXFSZ, queue_phup);
 #endif
 
-	if (quitit == 0 && arginp == 0) {
+	if (quitit == 0 && targinp == 0) {
 #ifdef SIGTSTP
 	    (void) signal(SIGTSTP, SIG_IGN);
 #endif
@@ -1323,7 +1301,7 @@ main(int argc, char **argv)
  */
     sigset_interrupting(SIGCHLD, queue_pchild);
 
-    if (intty && !arginp) 	
+    if (intty && !targinp) 	
 	(void) ed_Setup(editing);/* Get the tty state, and set defaults */
 				 /* Only alter the tty state if editing */
     
@@ -1358,7 +1336,7 @@ main(int argc, char **argv)
 #ifdef _PATH_DOTCSHRC
 	    (void) srcfile(_PATH_DOTCSHRC, 0, 0, NULL);
 #endif
-	    if (!arginp && !onelflg && !havhash)
+	    if (!targinp && !onelflg && !havhash)
 		dohash(NULL,NULL);
 #ifndef LOGINFIRST
 #ifdef _PATH_DOTLOGIN
@@ -1378,7 +1356,7 @@ main(int argc, char **argv)
 	if (!srccat(varval(STRhome), STRsldottcshrc))
 	    (void) srccat(varval(STRhome), STRsldotcshrc);
 
-	if (!arginp && !onelflg && !havhash)
+	if (!targinp && !onelflg && !havhash)
 	    dohash(NULL,NULL);
 
 	/*
@@ -1398,7 +1376,7 @@ main(int argc, char **argv)
     exitset--;
 
     /* Initing AFTER .cshrc is the Right Way */
-    if (intty && !arginp) {	/* PWP setup stuff */
+    if (intty && !targinp) {	/* PWP setup stuff */
 	ed_Init();		/* init the new line editor */
 #ifdef SIG_WINDOW
 	check_window_size(1);	/* mung environment */
@@ -1413,6 +1391,32 @@ main(int argc, char **argv)
     if (nexececho)
 	setNS(STRecho);
     
+
+    if (targinp) {
+	arginp = SAVE(targinp);
+	/*
+	 * we put the command into a variable
+	 */
+	if (arginp != NULL)
+	    setv(STRcommand, quote(Strsave(arginp)), VAR_READWRITE);
+
+	/*
+	 * * Give an error on -c arguments that end in * backslash to
+	 * ensure that you don't make * nonportable csh scripts.
+	 */
+	{
+	    int count;
+
+	    cp = Strend(arginp);
+	    count = 0;
+	    while (cp > arginp && *--cp == '\\')
+		++count;
+	    if ((count & 1) != 0) {
+		exiterr = 1;
+		stderror(ERR_ARGC);
+	    }
+	}
+    }
     /*
      * All the rest of the world is inside this call. The argument to process
      * indicates whether it should catch "error unwinds".  Thus if we are a

Modified: vendor/tcsh/dist/sh.func.c
==============================================================================
--- vendor/tcsh/dist/sh.func.c	Sat Mar 25 13:33:23 2017	(r315949)
+++ vendor/tcsh/dist/sh.func.c	Sat Mar 25 14:09:12 2017	(r315950)
@@ -2734,16 +2734,18 @@ nlsclose(void)
 int
 getYN(const char *prompt)
 {
-    int doit, c;
+    int doit;
+    char c;
+
     xprintf("%s", prompt);
     flush();
-    (void) force_read(SHIN, &c, 1);
+    (void) force_read(SHIN, &c, sizeof(c));
     /* 
      * Perhaps we should use the yesexpr from the
      * actual locale
      */
     doit = (strchr(CGETS(22, 14, "Yy"), c) != NULL);
-    while (c != '\n' && force_read(SHIN, &c, 1) == 1)
+    while (c != '\n' && force_read(SHIN, &c, sizeof(c)) == sizeof(c))
 	continue;
     return doit;
 }

Modified: vendor/tcsh/dist/tw.init.c
==============================================================================
--- vendor/tcsh/dist/tw.init.c	Sat Mar 25 13:33:23 2017	(r315949)
+++ vendor/tcsh/dist/tw.init.c	Sat Mar 25 14:09:12 2017	(r315950)
@@ -125,9 +125,8 @@ tw_str_add(stringlist_t *sl, size_t len)
 	sl->buff = xrealloc(sl->buff, sl->tbuff * sizeof(Char));
 	/* Re-thread the new pointer list, if changed */
 	if (ptr != NULL && ptr != sl->buff) {
-	    intptr_t offs = sl->buff - ptr;
 	    for (i = 0; i < sl->nlist; i++)
-		sl->list[i] += offs;
+		sl->list[i] = sl->buff + (sl->list[i] - ptr);
 	}
 	disabled_cleanup(&pintr_disabled);
     }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703251409.v2PE9D7f016807>