summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-01-13 21:14:34 +0100
committerDan McGee <dan@archlinux.org>2008-01-14 01:42:00 +0100
commit549c2878f965e5b6cb001ff3c8c5e3122becf8e1 (patch)
tree4433139a39b18a7802e2212c8c523598b2192780 /src
parent8186dc11a90dbc310acaad7ee867ee995adbd6ed (diff)
downloadpacman-549c2878f965e5b6cb001ff3c8c5e3122becf8e1.tar.gz
pacman-549c2878f965e5b6cb001ff3c8c5e3122becf8e1.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/pacman.c4
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);
}