On Mon, Jun 21, 2021 at 11:26 PM <minf...@apache.org> wrote:
>
> Author: minfrin
> Date: Mon Jun 21 21:26:54 2021
> New Revision: 1890952
[]
>
> +APR_DECLARE(apr_status_t) apr_dbm_get_driver(const apr_dbm_driver_t **vtable,
> +        const char *type, const apu_err_t **result, apr_pool_t *pool)
>  {
[]
> +
> +    if (result && !*result) {
> +        char *buffer = apr_pcalloc(pool, ERROR_SIZE);

Maybe use :
           apr_status_t rv = APR_ENOTIMPL;
           char *buffer = apr_psprintf(pool, "%pm", &rv);

to avoid arbitrary ERROR_SIZE allocation?

> +        apu_err_t *err = apr_pcalloc(pool, sizeof(apu_err_t));
> +        if (err && buffer) {
> +            apr_strerror(APR_ENOTIMPL, buffer, ERROR_SIZE - 1);
> +            err->msg = buffer;
> +            err->reason = apr_pstrdup(pool, type);
> +            *result = err;
> +        }
> +    }
> +
>      return APR_ENOTIMPL;
>
>  #else /* APR_HAVE_MODULAR_DSO */
>
[]
> +
> +    if (APR_SUCCESS != rv && result && !*result) {
> +        char *buffer = apr_pcalloc(pool, ERROR_SIZE);

Same here.

> +        apu_err_t *err = apr_pcalloc(pool, sizeof(apu_err_t));
> +        if (err && buffer) {
> +            apr_dso_error(dso, buffer, ERROR_SIZE - 1);
> +            err->msg = buffer;
> +            err->reason = apr_pstrdup(pool, modname);
> +            *result = err;
> +        }
> +    }
> +
>      return rv;

Regards;
Yann.

Reply via email to