Patch for NCSA httpd 1.1 seg fault problem

burchard@geom.umn.edu
Mon, 7 Feb 1994 11:00:19 --100


NCSA httpd 1.1 assumes getenv("PATH") returns non-NULL.
This fails for example on our SGI Irix 4.0.5 server
running from inetd. Here is a patch to correct the
situation...sorry if this has already been mentioned.

*** httpd.h~ Fri Feb 4 17:48:47 1994
--- httpd.h Fri Feb 4 17:48:50 1994
***************
*** 213,218 ****
--- 213,221 ----
/* The name of the access file */
#define ACCESS_CONFIG_FILE "conf/access.conf"

+ /* Default PATH to be inherited by server scripts */
+ #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
+

/* Whether we should enable rfc931 identity checking */
#define DEFAULT_RFC931 0
/* The default directory in user's home dir */
*** http_script.c~ Fri Feb 4 17:46:43 1994
--- http_script.c Fri Feb 4 17:57:30 1994
***************
*** 73,79 ****
int content, nph;
char cl[MAX_STRING_LEN],t[MAX_STRING_LEN],t2[MAX_STRING_LEN];
char path_args[MAX_STRING_LEN];
! char *argv0,**env;
FILE *psin;
struct stat finfo;
register int n,x;
--- 73,79 ----
int content, nph;
char cl[MAX_STRING_LEN],t[MAX_STRING_LEN],t2[MAX_STRING_LEN];
char path_args[MAX_STRING_LEN];
! char *argv0,**env,*env_path;
FILE *psin;
struct stat finfo;
register int n,x;
***************
*** 97,103 ****
if(!(env = (char **)malloc((MAX_CGI_VARS + 2) * sizeof(char *))))
die(NO_MEMORY,"exec_cgi_script",out);
n = 0;
! env[n++] = make_env_str("PATH",getenv("PATH"),out);
env[n++] = make_env_str("SERVER_SOFTWARE",SERVER_VERSION,out);
env[n++] = make_env_str("SERVER_NAME",server_hostname,out);
env[n++] = make_env_str("GATEWAY_INTERFACE","CGI/1.0",out);
--- 97,104 ----
if(!(env = (char **)malloc((MAX_CGI_VARS + 2) * sizeof(char *))))
die(NO_MEMORY,"exec_cgi_script",out);
n = 0;
! if(!(env_path = getenv("PATH"))) env_path = DEFAULT_PATH;
! env[n++] = make_env_str("PATH",env_path,out);
env[n++] = make_env_str("SERVER_SOFTWARE",SERVER_VERSION,out);
env[n++] = make_env_str("SERVER_NAME",server_hostname,out);
env[n++] = make_env_str("GATEWAY_INTERFACE","CGI/1.0",out);

--------------------------------------------------------------------
Paul Burchard <burchard@geom.umn.edu>
``I'm still learning how to count backwards from infinity...''
--------------------------------------------------------------------