Module Name:    xsrc
Committed By:   mrg
Date:           Mon Jul 11 08:49:36 UTC 2022

Modified Files:
        xsrc/external/mit/xconsole/dist: xconsole.c
        xsrc/external/mit/xmodmap/dist: handle.c
Removed Files:
        xsrc/external/mit/xcmsdb/dist: README
        xsrc/external/mit/xconsole/dist: README
        xsrc/external/mit/xwud/dist: README

Log Message:
merge xcmsdb 1.0.6, xconsole 1.0.8, xmodmap 1.0.11, and xwud 1.0.6.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/xcmsdb/dist/README
cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/xconsole/dist/README
cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/xconsole/dist/xconsole.c
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/xmodmap/dist/handle.c
cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/xwud/dist/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xconsole/dist/xconsole.c
diff -u xsrc/external/mit/xconsole/dist/xconsole.c:1.5 xsrc/external/mit/xconsole/dist/xconsole.c:1.6
--- xsrc/external/mit/xconsole/dist/xconsole.c:1.5	Mon Mar 17 09:20:46 2014
+++ xsrc/external/mit/xconsole/dist/xconsole.c	Mon Jul 11 08:49:36 2022
@@ -178,7 +178,6 @@ static XrmOptionDescRec options[] = {
 # if defined(TIOCCONS) || defined(SRIOCSREDIR)
 #  define USE_PTY
 static int  tty_fd, pty_fd;
-static char ttydev[64], ptydev[64];
 # endif
 #endif
 
@@ -188,7 +187,7 @@ static char ttydev[64], ptydev[64];
 #endif
 
 #ifdef USE_PTY
-static int get_pty(int *pty, int *tty, char *ttydev, char *ptydev);
+static int get_pty(int *pty, int *tty);
 #endif
 
 #ifdef USE_OSM
@@ -243,7 +242,7 @@ OpenConsole(void)
 #endif
 
 #ifdef USE_PTY
-		if (!input && get_pty (&pty_fd, &tty_fd, ttydev, ptydev) == 0)
+		if (!input && get_pty (&pty_fd, &tty_fd) == 0)
 		{
 # ifdef TIOCCONS
 		    int on = 1;
@@ -789,14 +788,17 @@ ScrollLine(Widget w)
  */
 
 static int
-get_pty(int *pty, int *tty, char *ttydev, char *ptydev)
+get_pty(int *pty, int *tty)
 {
 #ifdef HAS_OPENPTY
 	if (openpty(pty, tty, NULL, NULL, NULL) == -1) {
 		return 1;
 	}
 	return 0;
-#elif defined (SVR4) || defined (USE_PTS)
+#else
+	static char ttydev[64], ptydev[64];
+
+#if defined (SVR4) || defined (USE_PTS)
 #if defined (_AIX)
 	if ((*pty = open ("/dev/ptc", O_RDWR)) < 0)
 #else
@@ -823,14 +825,6 @@ get_pty(int *pty, int *tty, char *ttydev
 #else
 	static int devindex, letter = 0;
 
-#ifdef sgi
-	{
-	    char *slave;
-	    slave = _getpty (pty, O_RDWR, 0622, 0);
-	    if ((*tty = open (slave, O_RDWR)) != -1)
-		return 0;
-	}
-#else
 	strcpy (ttydev, "/dev/ttyxx");
 	strcpy (ptydev, "/dev/ptyxx");
 	while (PTYCHAR1[letter]) {
@@ -857,7 +851,6 @@ get_pty(int *pty, int *tty, char *ttydev
 	    devindex = 0;
 	    (void) letter++;
 	}
-#endif /* sgi else not sgi */
 #endif /* USE_GET_PSEUDOTTY */
 #endif /* SVR4 */
 	/*
@@ -865,6 +858,7 @@ get_pty(int *pty, int *tty, char *ttydev
 	 * condition and let our caller terminate cleanly.
 	 */
 	return(1);
+#endif /* HAS_OPENPTY */
 }
 #endif
 

Index: xsrc/external/mit/xmodmap/dist/handle.c
diff -u xsrc/external/mit/xmodmap/dist/handle.c:1.2 xsrc/external/mit/xmodmap/dist/handle.c:1.3
--- xsrc/external/mit/xmodmap/dist/handle.c:1.2	Sun Jul 19 23:13:49 2015
+++ xsrc/external/mit/xmodmap/dist/handle.c	Mon Jul 11 08:49:36 2022
@@ -37,6 +37,7 @@ from The Open Group.
 #include "xmodmap.h"
 #include "wq.h"
 #include <stdlib.h>
+#include <stdint.h>
 
 #ifdef HAVE_STRNCASECMP
 #include <strings.h>
@@ -59,6 +60,26 @@ struct wq work_queue = {NULL, NULL};
  * common utility routines
  */
 
+/*
+ * This is a combination of reallocf() and reallocarray().
+ * If the realloc fails, it frees the old pointer so it doesn't leak.
+ */
+static void *
+reallocfarray(void *old, size_t num, size_t size)
+{
+    static void *new;
+
+    if (size > 0 && num > (SIZE_MAX / size)) /* overflow would happen */
+        new = NULL;
+    else
+        new = realloc(old, num * size);
+
+    if (new == NULL)
+        free(old);
+
+    return new;
+}
+
 static KeyCode *
 KeysymToKeycodes(Display *dpy, KeySym keysym, int *pnum_kcs)
 {
@@ -72,7 +93,12 @@ KeysymToKeycodes(Display *dpy, KeySym ke
 		if (!kcs)
 		    kcs = malloc(sizeof(KeyCode));
 		else
-		    kcs = realloc(kcs, sizeof(KeyCode) * (*pnum_kcs + 1));
+		    kcs = reallocfarray(kcs, (*pnum_kcs + 1), sizeof(KeyCode));
+		if (!kcs) {
+		    fprintf(stderr, "attempt to allocate %ld byte keycode set",
+			    (long) ((*pnum_kcs + 1) * sizeof (KeyCode)));
+		    return NULL;
+		}
 		kcs[*pnum_kcs] = i;
 		*pnum_kcs += 1;
 		break;
@@ -690,7 +716,7 @@ do_remove(char *line, int len)
 	}
 	if (nc + num_kcs > tot) {
 	    tot = nc + num_kcs;
-	    kclist = realloc(kclist, tot * sizeof(KeyCode));
+	    kclist = reallocfarray(kclist, tot, sizeof(KeyCode));
 	    if (!kclist) {
 		badmsg ("attempt to allocate %ld byte keycode list",
 			(long) (tot * sizeof (KeyCode)));
@@ -708,6 +734,7 @@ do_remove(char *line, int len)
     if (!uop) {
 	badmsg ("attempt to allocate %ld byte removemodifier opcode",
 		(long) sizeof (struct op_removemodifier));
+	free(kclist);
 	return;
     }
     oprm = &uop->removemodifier;
@@ -889,8 +916,16 @@ do_pointer(char *line, int len)
     }
     
     if (i > 0 && i != nbuttons) {
-	fprintf (stderr, "Warning: Only changing the first %d of %d buttons.\n",
-		 i, nbuttons);
+	if (i < nbuttons) {
+	    fprintf (stderr, 
+		     "Warning: Only changing the first %d of %d buttons.\n",
+		     i, nbuttons);
+	}
+	else {  /* i > nbuttons */ 
+	    fprintf (stderr, 
+		     "Warning: Not changing %d extra buttons beyond %d.\n",
+		     i - nbuttons, nbuttons);
+	}
 	i = nbuttons;
     }
 
@@ -974,13 +1009,11 @@ get_keysym_list(const char *line, int le
 
 	/* grow the list bigger if necessary */
 	if (havesofar >= maxcanhave) {
-	    KeySym *origkeysymlist = keysymlist;
 	    maxcanhave *= 2;
-	    keysymlist = realloc (keysymlist, maxcanhave * sizeof (KeySym));
+	    keysymlist = reallocfarray(keysymlist, maxcanhave, sizeof(KeySym));
 	    if (!keysymlist) {
 		badmsg ("attempt to grow keysym list to %ld bytes",
 			(long) (maxcanhave * sizeof (KeySym)));
-		free(origkeysymlist);
 		return (-1);
 	    }
 	}

Reply via email to