FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 07-23-2012, 03:18 AM
Allan McRae
 
Default query_fileowner: remove trailing '/' from targets

On 23/07/12 03:30, Andrew Gregory wrote:
> Trailing '/' in paths causes lstat to dereference symlinks to directories which
> causes it to break even though the symlink is a valid target.
>
> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
> ---
> src/pacman/query.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/pacman/query.c b/src/pacman/query.c
> index 84c9d3b..dca45e7 100644
> --- a/src/pacman/query.c
> +++ b/src/pacman/query.c
> @@ -136,6 +136,12 @@ static int query_fileowner(alpm_list_t *targets)
>
> filename = strdup(t->data);
>
> + /* trailing '/' causes lstat to resolve directory symlinks */
> + size_t len = strlen(filename) - 1;
> + while(len > 0 && filename[len] == '/'){
> + filename[len] = '';
> + }

while? Are you wanting to remove multiple trailing '/' at the and of
the path and forgot to add a decrement here?

> +
> if(lstat(filename, &buf) == -1) {
> /* if it is not a path but a program name, then check in PATH */
> if(strchr(filename, '/') == NULL) {
>
 
Old 07-26-2012, 05:45 AM
Allan McRae
 
Default query_fileowner: remove trailing '/' from targets

On 26/07/12 15:04, Andrew Gregory wrote:
> Trailing '/' in paths causes lstat to dereference symlinks to directories which
> causes it to break even though the symlink is a valid target.
>
> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
> ---
> src/pacman/query.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/pacman/query.c b/src/pacman/query.c
> index 176f91c..d145707 100644
> --- a/src/pacman/query.c
> +++ b/src/pacman/query.c
> @@ -137,6 +137,12 @@ static int query_fileowner(alpm_list_t *targets)
>
> filename = strdup(t->data);
>
> + /* trailing '/' causes lstat to dereference directory symlinks */
> + size_t len = strlen(filename) - 1;

The current style is to declare all variables at the start of the
function. I made that adjustment and pushed to my working branch.

Allan
 

Thread Tools




All times are GMT. The time now is 01:34 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org