dgaudet 98/02/02 23:28:46
Modified: src/modules/standard mod_cgi.c
Log:
r->finfo isn't a scratch space, it contains information about r->filename
so create a scratch space when we need to scratch.
r->finfo.st_mode == 0 should be tested before other things involving
r->finfo.
Revision Changes Path
1.70 +9 -7 apache-1.3/src/modules/standard/mod_cgi.c
Index: mod_cgi.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_cgi.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- mod_cgi.c 1998/01/28 11:33:27 1.69
+++ mod_cgi.c 1998/02/03 07:28:45 1.70
@@ -163,13 +163,14 @@
int show_errno, char *error)
{
FILE *f;
+ struct stat finfo;
aplog_error(APLOG_MARK, show_errno|APLOG_ERR, r->server,
"%s, reason: %s", error, r->filename);
if (!conf->logname ||
- ((stat(server_root_relative(r->pool, conf->logname), &r->finfo) == 0)
- && (r->finfo.st_size > conf->logbytes)) ||
+ ((stat(server_root_relative(r->pool, conf->logname), &finfo) == 0)
+ && (finfo.st_size > conf->logbytes)) ||
((f = pfopen(r->pool, server_root_relative(r->pool, conf->logname),
"a")) == NULL)) {
return ret;
@@ -195,10 +196,11 @@
char argsbuffer[HUGE_STRING_LEN];
FILE *f;
int i;
+ struct stat finfo;
if (!conf->logname ||
- ((stat(server_root_relative(r->pool, conf->logname), &r->finfo) == 0)
- && (r->finfo.st_size > conf->logbytes)) ||
+ ((stat(server_root_relative(r->pool, conf->logname), &finfo) == 0)
+ && (finfo.st_size > conf->logbytes)) ||
((f = pfopen(r->pool, server_root_relative(r->pool, conf->logname),
"a")) == NULL)) {
/* Soak up script output */
@@ -375,9 +377,6 @@
return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
"attempt to include NPH CGI script");
- if (S_ISDIR(r->finfo.st_mode))
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "attempt to invoke directory as script");
#if defined(__EMX__) || defined(WIN32)
/* Allow for cgi files without the .EXE extension on them under OS/2 */
if (r->finfo.st_mode == 0) {
@@ -395,6 +394,9 @@
return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
"script not found or unable to stat");
#endif
+ if (S_ISDIR(r->finfo.st_mode))
+ return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
+ "attempt to invoke directory as script");
if (!suexec_enabled) {
if (!can_exec(&r->finfo))
return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,