On 01/24/18 at 07:20pm, [email protected] wrote:
> From: Ivy Foster <[email protected]>
> 
> Query operations act on the local db, not the filesystem. Also, a
> valid use case for -Qo is to discover what package owns a deleted file
> so it can be reinstalled.
> 
> Closes FS#55856.
> 
> Signed-off-by: Ivy Foster <[email protected]>
> ---
> My apologies for missing the earlier patch's problems with missing
> dirs. Frankly, I don't know how I missed it. This one really,
> honest-to-goodness *does* find missing dirs, as long the user passes
> the dirname with a slash at the end, as well as missing files. Enjoy!
> 
>  src/pacman/query.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/src/pacman/query.c b/src/pacman/query.c
> index 91ca78a7..39f8dabf 100644
> --- a/src/pacman/query.c
> +++ b/src/pacman/query.c

...

> @@ -206,7 +200,7 @@ static int query_fileowner(alpm_list_t *targets)
>  
>               rel_path = rpath + rootlen;
>  
> -             if((is_dir = S_ISDIR(buf.st_mode))) {
> +             if((is_missing && is_dir) || (is_dir = S_ISDIR(buf.st_mode))) {
>                       size_t rlen = strlen(rpath);
>                       if(rlen + 2 >= PATH_MAX) {
>                                       pm_printf(ALPM_LOG_ERROR, _("path too 
> long: %s/\n"), rpath);

The call to S_ISDIR needs to be moved up with the stat call(s) in
a branch where we know the stat succeeded.  If the file does not exist
the calls to stat will fail and buf.st_mode will be uninitialized.

apg

Reply via email to