mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +03:00
Initialize all ap_file_t's to NULL. This allows ap_open and ap_stat to
work together without causing memory leaks. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84393 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -823,7 +823,7 @@ static int include_cmd(char *s, request_rec *r)
|
|||||||
ap_status_t rc;
|
ap_status_t rc;
|
||||||
ap_table_t *env = r->subprocess_env;
|
ap_table_t *env = r->subprocess_env;
|
||||||
char **argv;
|
char **argv;
|
||||||
ap_file_t *file;
|
ap_file_t *file = NULL;
|
||||||
ap_iol *iol;
|
ap_iol *iol;
|
||||||
|
|
||||||
arg.r = r;
|
arg.r = r;
|
||||||
@@ -2347,7 +2347,7 @@ static const char *set_xbithack(cmd_parms *cmd, void *xbp, char *arg)
|
|||||||
|
|
||||||
static int send_parsed_file(request_rec *r)
|
static int send_parsed_file(request_rec *r)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
enum xbithack *state =
|
enum xbithack *state =
|
||||||
(enum xbithack *) ap_get_module_config(r->per_dir_config, &includes_module);
|
(enum xbithack *) ap_get_module_config(r->per_dir_config, &includes_module);
|
||||||
int errstatus;
|
int errstatus;
|
||||||
|
@@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
static int asis_handler(request_rec *r)
|
static int asis_handler(request_rec *r)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
ap_status_t status;
|
ap_status_t status;
|
||||||
const char *location;
|
const char *location;
|
||||||
|
|
||||||
|
@@ -939,7 +939,7 @@ static void do_emit_plain(request_rec *r, ap_file_t *f)
|
|||||||
static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
|
static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
|
||||||
char *title)
|
char *title)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
request_rec *rr = NULL;
|
request_rec *rr = NULL;
|
||||||
int emit_amble = 1;
|
int emit_amble = 1;
|
||||||
int emit_H1 = 1;
|
int emit_H1 = 1;
|
||||||
@@ -1022,7 +1022,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
|
|||||||
*/
|
*/
|
||||||
static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
|
static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
request_rec *rr = NULL;
|
request_rec *rr = NULL;
|
||||||
int suppress_post = 0;
|
int suppress_post = 0;
|
||||||
int suppress_sig = 0;
|
int suppress_sig = 0;
|
||||||
|
@@ -166,7 +166,7 @@ static const command_rec cgi_cmds[] =
|
|||||||
static int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
|
static int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
|
||||||
int show_errno, char *error)
|
int show_errno, char *error)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
struct stat finfo;
|
struct stat finfo;
|
||||||
|
|
||||||
ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, errno, r,
|
ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, errno, r,
|
||||||
@@ -198,7 +198,7 @@ static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
|
|||||||
ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
|
ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
|
||||||
ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
|
ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
|
||||||
char argsbuffer[HUGE_STRING_LEN];
|
char argsbuffer[HUGE_STRING_LEN];
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
int i;
|
int i;
|
||||||
struct stat finfo;
|
struct stat finfo;
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr
|
|||||||
ap_procattr_t *procattr;
|
ap_procattr_t *procattr;
|
||||||
ap_proc_t *procnew;
|
ap_proc_t *procnew;
|
||||||
ap_status_t rc = APR_SUCCESS;
|
ap_status_t rc = APR_SUCCESS;
|
||||||
ap_file_t *file;
|
ap_file_t *file = NULL;
|
||||||
ap_iol *iol;
|
ap_iol *iol;
|
||||||
|
|
||||||
#ifdef DEBUG_CGI
|
#ifdef DEBUG_CGI
|
||||||
|
@@ -666,7 +666,7 @@ static const command_rec cgid_cmds[] =
|
|||||||
static int log_scripterror(request_rec *r, cgid_server_conf * conf, int ret,
|
static int log_scripterror(request_rec *r, cgid_server_conf * conf, int ret,
|
||||||
int show_errno, char *error)
|
int show_errno, char *error)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
struct stat finfo;
|
struct stat finfo;
|
||||||
|
|
||||||
ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, errno, r,
|
ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, errno, r,
|
||||||
@@ -698,7 +698,7 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
|
|||||||
ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
|
ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
|
||||||
ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
|
ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
|
||||||
char argsbuffer[HUGE_STRING_LEN];
|
char argsbuffer[HUGE_STRING_LEN];
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
int i;
|
int i;
|
||||||
struct stat finfo;
|
struct stat finfo;
|
||||||
|
|
||||||
|
@@ -776,7 +776,7 @@ static char *lcase_header_name_return_body(char *header, request_rec *r)
|
|||||||
static int read_type_map(negotiation_state *neg, request_rec *rr)
|
static int read_type_map(negotiation_state *neg, request_rec *rr)
|
||||||
{
|
{
|
||||||
request_rec *r = neg->r;
|
request_rec *r = neg->r;
|
||||||
ap_file_t *map;
|
ap_file_t *map = NULL;
|
||||||
ap_status_t status;
|
ap_status_t status;
|
||||||
char buffer[MAX_STRING_LEN];
|
char buffer[MAX_STRING_LEN];
|
||||||
enum header_state hstate;
|
enum header_state hstate;
|
||||||
|
@@ -3394,9 +3394,9 @@ static void rewritelock_free(request_rec *r)
|
|||||||
static void run_rewritemap_programs(server_rec *s, ap_context_t *p)
|
static void run_rewritemap_programs(server_rec *s, ap_context_t *p)
|
||||||
{
|
{
|
||||||
rewrite_server_conf *conf;
|
rewrite_server_conf *conf;
|
||||||
ap_file_t *fpin;
|
ap_file_t *fpin = NULL;
|
||||||
ap_file_t *fpout;
|
ap_file_t *fpout = NULL;
|
||||||
ap_file_t *fperr;
|
ap_file_t *fperr = NULL;
|
||||||
ap_array_header_t *rewritemaps;
|
ap_array_header_t *rewritemaps;
|
||||||
rewritemap_entry *entries;
|
rewritemap_entry *entries;
|
||||||
rewritemap_entry *map;
|
rewritemap_entry *map;
|
||||||
|
@@ -935,7 +935,7 @@ static void tryit(request_rec *r, unsigned char *buf, int nb, int checkzmagic)
|
|||||||
*/
|
*/
|
||||||
static int apprentice(server_rec *s, ap_context_t *p)
|
static int apprentice(server_rec *s, ap_context_t *p)
|
||||||
{
|
{
|
||||||
ap_file_t *f;
|
ap_file_t *f = NULL;
|
||||||
ap_status_t result;
|
ap_status_t result;
|
||||||
char line[BUFSIZ + 1];
|
char line[BUFSIZ + 1];
|
||||||
int errs = 0;
|
int errs = 0;
|
||||||
@@ -2153,7 +2153,7 @@ static int uncompress_child(struct uncompress_parms *parm, ap_context_t *cntxt,
|
|||||||
ap_context_t *child_context = cntxt;
|
ap_context_t *child_context = cntxt;
|
||||||
ap_procattr_t *procattr;
|
ap_procattr_t *procattr;
|
||||||
ap_proc_t *procnew = NULL;
|
ap_proc_t *procnew = NULL;
|
||||||
ap_file_t *file;
|
ap_file_t *file = NULL;
|
||||||
ap_iol *iol;
|
ap_iol *iol;
|
||||||
|
|
||||||
ap_block_alarms();
|
ap_block_alarms();
|
||||||
|
@@ -1021,20 +1021,20 @@ void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *
|
|||||||
{
|
{
|
||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
cmd_parms parms;
|
cmd_parms parms;
|
||||||
struct stat finfo;
|
ap_file_t *finfo = NULL;
|
||||||
|
|
||||||
fname = ap_server_root_relative(p, fname);
|
fname = ap_server_root_relative(p, fname);
|
||||||
|
|
||||||
if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
|
if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
|
||||||
!(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
|
!(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
|
||||||
if (stat(fname, &finfo) == -1)
|
if (ap_stat(&finfo, fname, ptemp) != APR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't require conf/httpd.conf if we have a -C or -c switch */
|
/* don't require conf/httpd.conf if we have a -C or -c switch */
|
||||||
if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
|
if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
|
||||||
!(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
|
!(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
|
||||||
if (stat(fname, &finfo) == -1)
|
if (ap_stat(&finfo, fname, ptemp) != APR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
server/log.c
11
server/log.c
@@ -204,7 +204,7 @@ static void open_error_log(server_rec *s, ap_context_t *p)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (*s->error_fname == '|') {
|
if (*s->error_fname == '|') {
|
||||||
ap_file_t *dummy;
|
ap_file_t *dummy = NULL;
|
||||||
|
|
||||||
/* This starts a new process... */
|
/* This starts a new process... */
|
||||||
rc = log_child (p, s->error_fname+1, &dummy);
|
rc = log_child (p, s->error_fname+1, &dummy);
|
||||||
@@ -299,7 +299,7 @@ void ap_open_logs(server_rec *s_main, ap_context_t *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT(void) ap_error_log2stderr(server_rec *s) {
|
API_EXPORT(void) ap_error_log2stderr(server_rec *s) {
|
||||||
ap_file_t *errfile;
|
ap_file_t *errfile = NULL;
|
||||||
|
|
||||||
ap_open_stderr(&errfile, s->process->pool);
|
ap_open_stderr(&errfile, s->process->pool);
|
||||||
if ( s->error_log != NULL) {
|
if ( s->error_log != NULL) {
|
||||||
@@ -513,8 +513,7 @@ API_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
|
|||||||
|
|
||||||
void ap_log_pid(ap_context_t *p, const char *fname)
|
void ap_log_pid(ap_context_t *p, const char *fname)
|
||||||
{
|
{
|
||||||
ap_file_t *pid_file;
|
ap_file_t *pid_file = NULL;
|
||||||
struct stat finfo;
|
|
||||||
static pid_t saved_pid = -1;
|
static pid_t saved_pid = -1;
|
||||||
pid_t mypid;
|
pid_t mypid;
|
||||||
|
|
||||||
@@ -523,7 +522,7 @@ void ap_log_pid(ap_context_t *p, const char *fname)
|
|||||||
|
|
||||||
fname = ap_server_root_relative(p, fname);
|
fname = ap_server_root_relative(p, fname);
|
||||||
mypid = getpid();
|
mypid = getpid();
|
||||||
if (mypid != saved_pid && stat(fname, &finfo) == 0) {
|
if (mypid != saved_pid && ap_stat(&pid_file, fname, p) == 0) {
|
||||||
/* WINCH and HUP call this on each restart.
|
/* WINCH and HUP call this on each restart.
|
||||||
* Only warn on first time through for this pid.
|
* Only warn on first time through for this pid.
|
||||||
*
|
*
|
||||||
@@ -740,7 +739,7 @@ API_EXPORT(void) ap_close_piped_log(piped_log *pl)
|
|||||||
API_EXPORT(piped_log *) ap_open_piped_log(ap_context_t *p, const char *program)
|
API_EXPORT(piped_log *) ap_open_piped_log(ap_context_t *p, const char *program)
|
||||||
{
|
{
|
||||||
piped_log *pl;
|
piped_log *pl;
|
||||||
ap_file_t *dummy;
|
ap_file_t *dummy = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = log_child(p, program, &dummy);
|
rc = log_child(p, program, &dummy);
|
||||||
|
@@ -548,7 +548,7 @@ static int lock_fd = -1;
|
|||||||
*/
|
*/
|
||||||
static void accept_mutex_init(ap_context_t *p)
|
static void accept_mutex_init(ap_context_t *p)
|
||||||
{
|
{
|
||||||
ap_file_t *tempfile;
|
ap_file_t *tempfile = NULL;
|
||||||
lock_it.l_whence = SEEK_SET; /* from current point */
|
lock_it.l_whence = SEEK_SET; /* from current point */
|
||||||
lock_it.l_start = 0; /* -"- */
|
lock_it.l_start = 0; /* -"- */
|
||||||
lock_it.l_len = 0; /* until end of file */
|
lock_it.l_len = 0; /* until end of file */
|
||||||
@@ -623,7 +623,7 @@ static ap_status_t accept_mutex_cleanup(void *foo)
|
|||||||
*/
|
*/
|
||||||
static void accept_mutex_child_init(ap_context_t *p)
|
static void accept_mutex_child_init(ap_context_t *p)
|
||||||
{
|
{
|
||||||
ap_file_t *tempfile;
|
ap_file_t *tempfile = NULL;
|
||||||
ap_status_t ret;
|
ap_status_t ret;
|
||||||
|
|
||||||
ret=ap_open(&tempfile, ap_lock_fname, APR_WRITE, APR_UREAD|APR_UWRITE, p);
|
ret=ap_open(&tempfile, ap_lock_fname, APR_WRITE, APR_UREAD|APR_UWRITE, p);
|
||||||
@@ -641,7 +641,7 @@ static void accept_mutex_child_init(ap_context_t *p)
|
|||||||
*/
|
*/
|
||||||
static void accept_mutex_init(ap_context_t *p)
|
static void accept_mutex_init(ap_context_t *p)
|
||||||
{
|
{
|
||||||
ap_file_t *tempfile;
|
ap_file_t *tempfile = NULL;
|
||||||
ap_status_t ret;
|
ap_status_t ret;
|
||||||
|
|
||||||
expand_lock_fname(p);
|
expand_lock_fname(p);
|
||||||
|
@@ -765,7 +765,7 @@ static void *cfg_getstr(void *buf, size_t bufsiz, void *param)
|
|||||||
API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p, const char *name)
|
API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p, const char *name)
|
||||||
{
|
{
|
||||||
configfile_t *new_cfg;
|
configfile_t *new_cfg;
|
||||||
ap_file_t *file;
|
ap_file_t *file = NULL;
|
||||||
ap_status_t stat;
|
ap_status_t stat;
|
||||||
ap_filetype_e type;
|
ap_filetype_e type;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user