[pacman-dev] [PATCH] Handle empty string passed to query_owner
Andrew Gregory
andrew.gregory.8 at gmail.com
Wed May 10 22:18:51 UTC 2017
On 05/09/17 at 03:46pm, Allan McRae wrote:
> 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.
I don't think we should ever fail silently. I would include an error
the same as any other path we can't resolve.
> 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