From: William A. Rowe Jr Date: Thu, 29 Nov 2001 06:56:09 +0000 (+0000) Subject: Prevent Apache from continuing to start when it's encountered a parsing X-Git-Tag: 2.0.30~340 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=398bb6bde92591aa8dc2d771d2e68f61a98c0e0a;p=apache Prevent Apache from continuing to start when it's encountered a parsing error in the Win32 mpm's argv[] review. Reported by Grif Rosser git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92239 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b042e1237d..9f1b3cf89c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.30-dev + *) Prevent the Win32 port from continuing after encountering an + error in the command line args to apache. [William Rowe] + *) On a error in the proxy, make it write a line to the error log [Ian Holsman] diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 2f0e0a5efa..d3ef6daf26 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -1691,8 +1691,9 @@ void winnt_rewrite_args(process_rec *process) optbuf[0] = '-'; optbuf[2] = '\0'; apr_getopt_init(&opt, process->pool, process->argc, (char**) process->argv); - while (apr_getopt(opt, "n:k:iu" AP_SERVER_BASEARGS, - optbuf + 1, &optarg) == APR_SUCCESS) { + opt->errfn = NULL; + while ((rv = apr_getopt(opt, "n:k:iu" AP_SERVER_BASEARGS, + optbuf + 1, &optarg)) == APR_SUCCESS) { switch (optbuf[1]) { case 'n': service_set = mpm_service_set_name(process->pool, &service_name, @@ -1722,6 +1723,16 @@ void winnt_rewrite_args(process_rec *process) } } + /* back up to capture the bad argument */ + if (rv == APR_BADCH || rv == APR_BADARG) { + opt->ind--; + } + + while (opt->ind < opt->argc) { + *(const char **)apr_array_push(mpm_new_argv) = + apr_pstrdup(process->pool, opt->argv[opt->ind++]); + } + /* Track the number of args actually entered by the user */ inst_argc = mpm_new_argv->nelts - fixed_args;