diff options
author | Dan McGee <dan@archlinux.org> | 2008-01-13 14:14:34 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-01-13 18:42:00 -0600 |
commit | 549c2878f965e5b6cb001ff3c8c5e3122becf8e1 (patch) | |
tree | 4433139a39b18a7802e2212c8c523598b2192780 | |
parent | 8186dc11a90dbc310acaad7ee867ee995adbd6ed (diff) |
Disallow a NULL section in _parseconfig
If we allow _parseconfig to continue processing when section is not defined,
then we have the potential to segfault during strcmp calls. This is no good.
For some reason, we had existing logic that tested this case but only if it
was processing and 'Include' directive. Expand the check to check for a NULL
section in all cases, and print an error message if this is the case.
Reported here:
http://bbs.archlinux.org/viewtopic.php?id=42235
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | src/pacman/pacman.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 1aa29682..27130254 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -606,8 +606,8 @@ static int _parseconfig(const char *file, const char *givensection, * follow the toupper() rules we may expect, e.g. tr_TR where i != I. */ upperkey = strtoupper(strdup(key)); - if(section == NULL && (strcmp(key, "Include") == 0 || strcmp(upperkey, "INCLUDE") == 0)) { - pm_printf(PM_LOG_ERROR, _("config file %s, line %d: 'Include' directive must belong to a section.\n"), + if(section == NULL) { + pm_printf(PM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"), file, linenum); return(1); } |