From b93dfa935f900d884f14d5be8949dc0ae85f1692 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sat, 27 Apr 2019 22:54:17 -0400 Subject: scripts: protect against unintended glob matching in [[ ]] RHS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The right-hand side of the [[ ... = ... ]] keyword is an exception to the general rule that quoting is unnecessary with [[ This is usually not a problem, e.g. in libmakepkg, lint_one_pkgname will already fail if pkgname has an asterisk, but it certainly doesn't hurt to be "more proper" and go with the spec; it is more dangerous in repo-add, which can get caught in an infinite loop instead of safely asserting there is no package named 'foo*'. Reported-by: Rafael Ascensão Signed-off-by: Eli Schwartz Signed-off-by: Allan McRae --- scripts/repo-add.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/repo-add.sh.in') diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 57413df5..e23f47c9 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -121,7 +121,7 @@ find_pkgentry() { for pkgentry in "$tmpdir/db/$pkgname"*; do name=${pkgentry##*/} - if [[ ${name%-*-*} = $pkgname ]]; then + if [[ ${name%-*-*} = "$pkgname" ]]; then echo $pkgentry return 0 fi @@ -464,7 +464,7 @@ remove() { error "$(gettext "Package matching '%s' not found.")" "$pkgname" return 1 fi - + return 0 } -- cgit v1.2.3-54-g00ecf