[pacman-dev] [PATCH] Handle empty string passed to query_owner

Allan McRae allan at archlinux.org
Tue May 9 05:46:31 UTC 2017


Passing an empty string to pacman -Qo results in:
error: No package owns <first directory in $PATH>

Treat an empty string being passed the same as recieving a NULL value
and exit searching for an owner.

Signed-off-by: Allan McRae <allan at archlinux.org>
---

Running 'pacman -Qo ""' will now just exit pacman. I'm not sure if we
need an error/warning message for this case.

 src/pacman/query.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pacman/query.c b/src/pacman/query.c
index a8417570..119764bc 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -161,7 +161,8 @@ static int query_fileowner(alpm_list_t *targets)
 		size_t len, is_dir;
 		unsigned int found = 0;
 
-		if((filename = strdup(t->data)) == NULL) {
+		filename = strdup(t->data);
+		if(filename == NULL || strcmp(filename, "") == 0) {
 			goto targcleanup;
 		}
 
-- 
2.12.2


More information about the pacman-dev mailing list