Author: Bernhard Übelacker <bernhardu@mailbox.org>
Bug-Debian: https://bugs.debian.org/1055607
Last-Update: 2023-11-25
Description: Looks like caused by having not enough space
 for process names longer than 13 characters.
 .
 A package built with the modification below
 shows no longer this crash.

--- a/hash.c
+++ b/hash.c
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <malloc.h>
+#include <string.h>
 #include "common.h"
 
 /*
@@ -73,7 +74,8 @@ addProc ( char *procname , int mem , int
       }
 /* printf("allocated %d procs\n",lastallocated); */
       thisproc = nextproc = procs ;
-      strcpy ( thisproc -> procname , procname ) ;
+      strncpy ( thisproc -> procname , procname , sizeof(thisproc -> procname) ) ;
+      thisproc -> procname[sizeof(thisproc -> procname)-1] = '\0';
       thisproc -> totMem = mem ;
       thisproc -> totRSS = rss ;
       thisproc -> nProcs = 1 ;
@@ -100,7 +102,8 @@ addProc ( char *procname , int mem , int
 /* printf("allocated %d procs\n",lastallocated); */
       }
       thisproc = procs + nProcs ;
-      strcpy ( thisproc -> procname , procname ) ;
+      strncpy ( thisproc -> procname , procname , sizeof(thisproc -> procname) ) ;
+      thisproc -> procname[sizeof(thisproc -> procname)-1] = '\0';
       thisproc -> totMem = mem ;
       thisproc -> totRSS = rss ;
       thisproc -> nProcs = 1 ;
