Skip to content

Commit 7dbe542

Browse files
committed
mod_log_config: better handle invalid log file name
if 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 7dbe542

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

modules/loggers/mod_log_config.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,11 +1916,21 @@ static int check_log_dir(apr_pool_t *p, server_rec *s, config_log_state *cls)
19161916
return OK;
19171917
}
19181918
else {
1919-
char *abs = ap_server_root_relative(p, cls->fname);
1920-
char *dir = ap_make_dirstr_parent(p, abs);
1919+
char *dir;
19211920
apr_finfo_t finfo;
1921+
apr_status_t rv;
19221922
const ap_directive_t *directive = cls->directive;
1923-
apr_status_t rv = apr_stat(&finfo, dir, APR_FINFO_TYPE, p);
1923+
char *abs = ap_server_root_relative(p, cls->fname);
1924+
if (!abs) {
1925+
ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0, s,
1926+
APLOGNO()
1927+
"Cannot construct log file path '%s' "
1928+
"defined at %s:%d", cls->fname,
1929+
directive->filename, directive->line_num);
1930+
return !OK;
1931+
}
1932+
dir = ap_make_dirstr_parent(p, abs);
1933+
rv = apr_stat(&finfo, dir, APR_FINFO_TYPE, p);
19241934
cls->directive = NULL; /* Don't check this config_log_state again */
19251935
if (rv == APR_SUCCESS && finfo.filetype != APR_DIR)
19261936
rv = APR_ENOTDIR;

0 commit comments

Comments
 (0)