summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-08-02 08:29:03 -0400
committerAllan McRae <allan@archlinux.org>2013-08-21 11:06:41 +1000
commitc02b16c4cc00f7b33aad79207c15fb651903e9ba (patch)
treec6c839ce67bf05d7357d39504b3eb4bc2bf35131
parent4d4f46ba2a9bb168f0e5f1139738c2cf4dc260ca (diff)
ini.c: give recursion limit file scope
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>
-rw-r--r--src/pacman/ini.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pacman/ini.c b/src/pacman/ini.c
index 2e677e00..cd7741db 100644
--- a/src/pacman/ini.c
+++ b/src/pacman/ini.c
@@ -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;
}