Bug 79114 - stunnel calls execvp with broken arguments
Summary: stunnel calls execvp with broken arguments
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Peter Pentchev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-22 08:00 UTC by hars
Modified: 2005-05-12 12:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hars 2005-03-22 08:00:16 UTC
       If execargs is not given in stunnel.conf, stunnel calls execvp with a NULL
       pointer as its second argument, which makes execvp fail with EFAIL.

Fix: 

execargs should be mandatory (and checked on startup),
        or something like the following should be done in client.c:
        if (NULL == c->opt->execargs) {
          char *args[] =  {c->opt->execname, NULL};
          execvp(c->opt->execname, args);
        } else {
	  execvp(c->opt->execname, c->opt->execargs);
	}
How-To-Repeat: 	I wrapped popa3d with stunnel, which worked on 4.x (modulo the spurious broken
        connection errors I filed a while ago) without execargs in stunnel.conf.
	I copied my configuration, and now every connection attempt leads to

         stunnel[13279]: /usr/local/libexec/popa3d: Bad address (14)
Comment 1 Volker Stolz freebsd_committer freebsd_triage 2005-03-22 13:26:41 UTC
Responsible Changed
From-To: freebsd-ports-bugs->roam

Over to maintainer
Comment 2 Peter Pentchev freebsd_committer freebsd_triage 2005-03-23 12:12:26 UTC
State Changed
From-To: open->analyzed

I'm looking into this...
Comment 3 hars 2005-03-23 13:32:52 UTC
Peter Pentchev wrote:
> I'm looking into this...

The sematics of execve changed a year ago, see
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_exec.c?f=h#rev1.238

This is the relevant part from execve(2):

      The argument argv is a pointer to a null-terminated array of character
      pointers to null-terminated character strings.  These strings construct
      the argument list to be made available to the new process.  At least one
      argument must be present in the array; by custom, the first element
      should be the name of the executed program (for example, the last compo-
      nent of path).


Yours, Florian.
Comment 4 Peter Pentchev freebsd_committer freebsd_triage 2005-05-12 12:36:53 UTC
State Changed
From-To: analyzed->closed

Fixed in the just-committed update to 4.10. 
Thanks for the problem report and the analysis!