Skip to content

Commit

Permalink
net/pload: fix crash at startup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
J.R. Oldroyd authored and clausecker committed Oct 9, 2023
1 parent 2346592 commit ffaf1c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions 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

Expand Down
10 changes: 6 additions & 4 deletions 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[])
{
Expand All @@ -10,23 +10,25 @@
+ /* 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();

+ /* XtAppInitialize() eats the arguments, so restore original
+ 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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ffaf1c4

Please sign in to comment.