From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Camm Maguire <camm@debian.org>
Date: Apr, 25 2026 08:37:10 +0000
Subject: [PATCH] <short summary of the patch>

TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-<Vendor>: <vendor-bugtracker-url>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>

--- xmpi-2.2.3b8.orig/src/libxmpi/xmpi_sys.lam.cc
+++ xmpi-2.2.3b8/src/libxmpi/xmpi_sys.lam.cc
@@ -220,13 +220,13 @@ xmpi_sys_run(char *aschema, struct _gps
 int
 xmpi_sys_kill(struct _gps *, int)
 {
-  char **av;			       /* cmd line args */
+  char **av,cmd[]="lamclean";	       /* cmd line args */
   int ac;			       /* # cmd line args */
   int r;			       /* result of lamclean */
 
   av = 0;
   ac = 0;
-  sfh_argv_add(&ac, &av, "lamclean");
+  sfh_argv_add(&ac, &av, cmd);
 
   r = _lam_few(av);
   sfh_argv_free(av);
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_ctl.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_ctl.cc
@@ -546,7 +546,7 @@ xmpi_ctl_setinfo(char *info)
 void
 xmpi_ctl_resetinfo()
 {
-  char fmtbuf[80];
+  char fmtbuf[256];
   char *app;
   const char *info = "<None>";
 
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_kiviat.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_kiviat.cc
@@ -432,7 +432,7 @@ plot()
 
   int fmtlen;			       /* string length */
 
-  char fmtbuf[8];		       /* formatting buffer */
+  char fmtbuf[11];		       /* formatting buffer */
 
   XCharStruct fmtinfo;		       /* string font info */
 
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_matrix.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_matrix.cc
@@ -535,7 +535,7 @@ mat_plot_grid()
 
   char *destxt, *srctxt;	       /* labels */
 
-  char fmtbuf[8];		       /* formatting buffer */
+  char fmtbuf[10];		       /* formatting buffer */
 
   XCharStruct fmtinfo;		       /* string font info */
 
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_run.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_run.cc
@@ -691,7 +691,10 @@ xmpi_run_set_prog(char* prog, char* dir)
 {
   strcpy(prog_dir, dir);
 
-  (void) chdir(prog_dir);
+  if (chdir(prog_dir)<0) {
+    xmpi_error(xmpi_run_w, (char*) "chdir failure", false);
+    return;
+  }
 
   if (prog && *prog) {
     XmTextFieldSetString(prog_w, prog);
@@ -758,7 +761,10 @@ run_run_cb(Widget w)
   xmpi_run_cleanup();
 
   strcpy(tempfile, "/tmp/xmpiXXXXXX");
-  mkstemp(tempfile);
+  if (mkstemp(tempfile)<0) {
+    xmpi_error(xmpi_run_w, (char*) "mkstemp fails.", false);
+    return;
+  }
   custom = tempfile;
 
   if (!run_save(custom)) {
@@ -808,14 +814,26 @@ run_save(char *filename)
     return LAMERROR;
   }
 
-  write(fd, header, strlen(header));
-  write(fd, "\n", 1);
+  if (write(fd, header, strlen(header))<0) {
+    xmpi_error(xmpi_run_w, (char*) "write failure", false);
+    return LAMERROR;
+  }
+  if (write(fd, "\n", 1)<0) {
+    xmpi_error(xmpi_run_w, (char*) "write failure", false);
+    return LAMERROR;
+  }
 
   for (i = 0; i < nitems; ++i) {
     XmStringGetLtoR(items[i], XmSTRING_DEFAULT_CHARSET,
 		    &progline);
-    write(fd, progline, strlen(progline));
-    write(fd, "\n", 1);
+    if (write(fd, progline, strlen(progline))<0) {
+      xmpi_error(xmpi_run_w, (char*) "write failure", false);
+      return LAMERROR;
+    }
+    if (write(fd, "\n", 1)<0) {
+      xmpi_error(xmpi_run_w, (char*) "write failure", false);
+      return LAMERROR;
+    }
     XtFree(progline);
   }
 
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_tr_segment.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_tr_segment.cc
@@ -43,7 +43,7 @@ xmpi_tr_select_segment(int maxseg)
 	Widget		dialog_w;		/* dialog to select segment */
 	XmString	str1, str2;		/* various strings */
 	Arg		args[3];
-	char		buf[32];		/* formatting buffer */
+	char		buf[40];		/* formatting buffer */
 /*
  * If there is only a single segment then no selection is necessary.
  */
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_trace.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_trace.cc
@@ -202,7 +202,7 @@ static double tmin;		       /* min trace
 static double tmax;		       /* max traces time */
 static struct xmarrow *arrows = 0;     /* array of arrows */
 static struct xmtrace *traces = 0;     /* array of traces */
-static char fmtbuf[80];		       /* formatting buffer */
+static char fmtbuf[268];		       /* formatting buffer */
 static int actionsinit = 0;	       /* actions initialized? */
 static int nbuoys;		       /* number of buoys */
 static struct xmbuoy *buoys = 0;       /* array of buoys */
@@ -1759,7 +1759,7 @@ setupdial()
 
   int i, y;
 
-  char numstr[8];
+  char numstr[9];
 
   GC maskgc;			       /* used in creating the mask */
 
--- xmpi-2.2.3b8.orig/src/xmpi/xmpi_vendor.cc
+++ xmpi-2.2.3b8/src/xmpi/xmpi_vendor.cc
@@ -309,7 +309,7 @@ draw_options_box(Widget mgr_w, xmpi_menu
 
 
       XtAddCallback((*options_widgets)[i], XmNvalueChangedCallback,
-		    text, (void*) i);
+		    text, (void*)(long)i);
       
       if (options[i].current_val.xmpi_text != NULL)
 	XmTextFieldInsert((*options_widgets)[i], 0, 
@@ -330,7 +330,7 @@ draw_options_box(Widget mgr_w, xmpi_menu
       XmStringFree(xstr);
 
       XtAddCallback((*options_widgets)[i], XmNvalueChangedCallback,
-		    toggle, (void*) i);
+		    toggle, (void*)(long) i);
 
       break;
 
@@ -363,7 +363,7 @@ draw_options_box(Widget mgr_w, xmpi_menu
 	XmStringFree(xstr);
 
 	XtAddCallback((*options_widgets)[i], XmNvalueChangedCallback,
-		      toggle, (void*) i);
+		      toggle, (void*)(long) i);
       }
       
       --i;  // since the for loop is about to increment...
