Commit dc06a7ab authored by Bill Stoddard's avatar Bill Stoddard
Browse files

Win32: Init the args to mpm_service_install(). Prevents nasty things like segfaults

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@155833 13f79535-47bb-0310-9956-ffa450edef68
parent 95715f01
Loading
Loading
Loading
Loading
+26 −22
Original line number Diff line number Diff line
@@ -1283,17 +1283,6 @@ void winnt_rewrite_args(process_rec *process)
                 "%s: Service is already installed.", service_name);
            exit(APEXIT_INIT);
        }
        else
        {
            /* Install the service */
            rv = mpm_service_install(process->pool, inst_argc, inst_argv, 0);
            if (rv != APR_SUCCESS) {
                exit(rv);
            }
            /* Proceed to post_config in order to test the installed configuration */
            fprintf(stderr,"Testing httpd.conf....\n");
            fprintf(stderr,"Errors reported here must be corrected before the service can be started.\n");
        }
    }
    else if (running_as_service)
    {
@@ -1339,24 +1328,39 @@ void winnt_rewrite_args(process_rec *process)
             "No installed service named \"%s\".", service_name);
        exit(APEXIT_INIT);
    }
    else if (!strcasecmp(signal_arg, "config")) 
    {

    /* Track the args actually entered by the user.
     * These will be used for the -k install parameters, as well as
     * for the -k start service override arguments.
     */
    inst_argv = (const char * const *)mpm_new_argv->elts
        + mpm_new_argv->nelts - inst_argc;

    /* Now, do service install or reconfigure then proceed to
     * post_config to test the installed configuration.
     */
    if (!strcasecmp(signal_arg, "config")) { /* -k config */
        /* Reconfigure the service */
        rv = mpm_service_install(process->pool, inst_argc, inst_argv, 1);
        if (rv != APR_SUCCESS) {
            exit(rv);
        }
        /* Proceed to post_config in order to test the installed configuration */

        fprintf(stderr,"Testing httpd.conf....\n");
        fprintf(stderr,"Errors reported here must be corrected before the service can be started.\n");
        fprintf(stderr,"Errors reported here must be corrected before the "
                "service can be started.\n");
    }
    else if (!strcasecmp(signal_arg, "install")) { /* -k install */
        /* Install the service */
        rv = mpm_service_install(process->pool, inst_argc, inst_argv, 0);
        if (rv != APR_SUCCESS) {
            exit(rv);
        }

    /* Track the args actually entered by the user.
     * These will be used for the -k install parameters, as well as
     * for the -k start service override arguments.
     */
    inst_argv = (const char * const *)mpm_new_argv->elts
        + mpm_new_argv->nelts - inst_argc;
        fprintf(stderr,"Testing httpd.conf....\n");
        fprintf(stderr,"Errors reported here must be corrected before the "
                "service can be started.\n");
    }

    process->argc = mpm_new_argv->nelts; 
    process->argv = (const char * const *) mpm_new_argv->elts;