diff mbox

[pacman-dev,v2] Handle empty string passed to query_owner

Message ID 20180109105038.15550-1-allan@archlinux.org
State Accepted, archived
Headers show

Commit Message

Allan McRae Jan. 9, 2018, 10:50 a.m. UTC
Passing an empty string to pacman -Qo results in:
error: No package owns <first directory in $PATH>

Catch empty strings and report an error.

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

FYI, v1 was submitted on 2017/05/11...  It was suggested I should not just
skip empty strings and instead report a letter.

 src/pacman/query.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/src/pacman/query.c b/src/pacman/query.c
index 024d3e21..4a37a338 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -165,6 +165,11 @@  static int query_fileowner(alpm_list_t *targets)
 			goto targcleanup;
 		}
 
+		if(strcmp(filename, "") == 0) {
+			pm_printf(ALPM_LOG_ERROR, _("empty string passed to file owner query\n"));
+			goto targcleanup;
+		}
+
 		/* trailing '/' causes lstat to dereference directory symlinks */
 		len = strlen(filename) - 1;
 		while(len > 0 && filename[len] == '/') {