Skip to content

Commit 2a91c15

Browse files
committed
core: error_log: better handle invalid error log file name
if error log file name is an invalid string, ap_server_root_relative will return NULL, which will result in SIGSEGV in ap_make_dirstr_parent
1 parent aee4aaf commit 2a91c15

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

server/core.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5316,15 +5316,24 @@ AP_DECLARE(int) ap_sys_privileges_handlers(int inc)
53165316

53175317
static int check_errorlog_dir(apr_pool_t *p, server_rec *s)
53185318
{
5319+
char *dir;
5320+
apr_finfo_t finfo;
5321+
apr_status_t rv;
5322+
53195323
if (!s->error_fname || s->error_fname[0] == '|'
53205324
|| s->errorlog_provider != NULL) {
53215325
return APR_SUCCESS;
53225326
}
53235327
else {
53245328
char *abs = ap_server_root_relative(p, s->error_fname);
5325-
char *dir = ap_make_dirstr_parent(p, abs);
5326-
apr_finfo_t finfo;
5327-
apr_status_t rv = apr_stat(&finfo, dir, APR_FINFO_TYPE, p);
5329+
if (!abs) {
5330+
ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0,
5331+
ap_server_conf, APLOGNO(02291)
5332+
"Cannot construct error log file path '%s'", s->error_fname);
5333+
return !OK;
5334+
}
5335+
dir = ap_make_dirstr_parent(p, abs);
5336+
rv = apr_stat(&finfo, dir, APR_FINFO_TYPE, p);
53285337
if (rv == APR_SUCCESS && finfo.filetype != APR_DIR)
53295338
rv = APR_ENOTDIR;
53305339
if (rv != APR_SUCCESS) {

0 commit comments

Comments
 (0)