]> wolfpit.net Git - tool/Arch-pacman/.git/commitdiff
ini.c: give recursion limit file scope
authorAndrew Gregory <andrew.gregory.8@gmail.com>
Fri, 2 Aug 2013 12:29:03 +0000 (08:29 -0400)
committerAllan McRae <allan@archlinux.org>
Wed, 21 Aug 2013 01:06:41 +0000 (11:06 +1000)
The recursion limit is an artificial limitation imposed to prevent
memory exhaustion in a recursive function.  Giving it file-level scope
increases its visibility.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
src/pacman/ini.c

index 2e677e00359bff314f84767d2081f835fde75f85..cd7741dbc9239e7a379b3cf7725e9e54075c9aa5 100644 (file)
@@ -27,6 +27,8 @@
 #include "ini.h"
 #include "util.h"
 
+static const int 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,
        FILE *fp = NULL;
        int linenum = 0;
        int ret = 0;
-       const int max_depth = 10;
 
-       if(depth >= max_depth) {
+       if(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;
        }