git: ffaf1c4515dd - main - net/pload: fix crash at startup

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Mon, 09 Oct 2023 07:41:58 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ffaf1c4515dd11fc28fd00c97ae5c8ff78aca4e1

commit ffaf1c4515dd11fc28fd00c97ae5c8ff78aca4e1
Author:     J.R. Oldroyd <fbsd@opal.com>
AuthorDate: 2023-10-08 17:59:09 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-10-09 07:40:32 +0000

    net/pload: fix crash at startup
    
    Looks like there was no NULL pointer at the end of the orig_argv[] when
    it was copied or restored.
    
    PR:             274354
    Reported by:    Rupert Stitzinger <stitzinger_rupert@web.de>
    MFH:            2023Q4
---
 net/pload/Makefile            |  4 ++--
 net/pload/files/patch-pload.c | 10 ++++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/net/pload/Makefile b/net/pload/Makefile
index 6aab9b94341c..a66efd39f478 100644
--- a/net/pload/Makefile
+++ b/net/pload/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	pload
-PORTVERSION=	0.9.5
-PORTREVISION=	5
+DISTVERSION=	0.9.5
+PORTREVISION=	6
 CATEGORIES=	net sysutils
 MASTER_SITES=	http://opal.com/src/pload/ LOCAL/pav
 
diff --git a/net/pload/files/patch-pload.c b/net/pload/files/patch-pload.c
index 9c6c17263337..6a03d7295163 100644
--- a/net/pload/files/patch-pload.c
+++ b/net/pload/files/patch-pload.c
@@ -1,6 +1,6 @@
 --- pload.c.orig	2000-02-01 07:11:24 UTC
 +++ pload.c
-@@ -285,6 +285,13 @@ static XtResource pload_resources[] = {
+@@ -285,6 +285,14 @@ static XtResource pload_resources[] = {
  /************* Main () ******************/
  int main (int argc, char *argv[])
  {
@@ -10,11 +10,12 @@
 +	/* save original argv pointers */
 +	for(i = 0; argv[i]; i++)
 +		orig_argv[i] = argv[i];
++        orig_argv[i] = NULL; /* add trailing NULL pointer */
 +
  	Progname = argv[0];
  	
  	toplevel = XtAppInitialize (
-@@ -301,6 +308,11 @@ int main (int argc, char *argv[])
+@@ -301,6 +309,12 @@ int main (int argc, char *argv[])
  	   and exit */	
  	if (argc != 1) Usage();
  	
@@ -22,11 +23,12 @@
 +	   argv so that ps(1) shows the command line */
 +	for(i = 0; orig_argv[i]; i++)
 +		argv[i] = orig_argv[i];
++	argv[i] = orig_argv[i];	/* copy trailing NULL pointer */
 +
  	XtGetApplicationResources(
  		toplevel,			/* widget */
  		(XtPointer) &resources, 	/* where to put */
-@@ -596,27 +608,26 @@ void CheckForWMExit(	Widget w, 
+@@ -596,27 +610,26 @@ void CheckForWMExit(	Widget w, 
  void do_total(char *b, double total)
  {
  	if (total < 1024.0)
@@ -62,7 +64,7 @@
  	return;
  }
  
-@@ -643,6 +654,9 @@ void make_label(char *fmt, unsigned long total, double
+@@ -643,6 +656,9 @@ void make_label(char *fmt, unsigned long total, double
  					break;
  				case 'M':
  					do_rate(buff, max);