[pacman-dev] [PATCH 7/9] ini.c: move recursion limit to a macro

Dave Reisner d at falconindy.com
Mon Jul 22 08:41:28 EDT 2013


On Jul 22, 2013 2:48 AM, "Andrew Gregory" <andrew.gregory.8 at gmail.com>
wrote:
>
> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> ---

OK... I'll bite. Why? Is this really going to be used elsewhere? Seems like
an error case that should be handled by the like any other.

>  src/pacman/ini.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/pacman/ini.c b/src/pacman/ini.c
> index 4d25f58..1c37f5c 100644
> --- a/src/pacman/ini.c
> +++ b/src/pacman/ini.c
> @@ -27,6 +27,8 @@
>  #include "ini.h"
>  #include "util.h"
>
> +#define INI_MAX_RECURSION 10
> +
>  /**
>   * @brief INI parser backend.
>   *
> @@ -46,11 +48,11 @@ static int _parse_ini(const char *file, ini_parser_fn
cb, void *data,
>         char line[PATH_MAX];
>         int linenum = 0;
>         int ret = 0;
> -       const int max_depth = 10;
>
> -       if(depth >= max_depth) {
> +       if(INI_MAX_RECURSION && depth >= INI_MAX_RECURSION) {
>                 pm_printf(ALPM_LOG_ERROR,
> -                               _("config parsing exceeded max recursion
depth of %d.\n"), max_depth);
> +                               _("config parsing exceeded max recursion
depth of %d.\n"),
> +                               INI_MAX_RECURSION);
>                 ret = 1;
>                 goto cleanup;
>         }
> --
> 1.8.3.3
>
>


More information about the pacman-dev mailing list