[pacman-dev] System hook dir contains a double slash

Allan McRae allan at archlinux.org
Sat Nov 28 06:37:28 UTC 2015


On 26/11/15 08:19, David Macek wrote:
> Hi all.
> 
> In `alpm_initialize`, there's
> 
> sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR);
> 
> where `SYSHOOKDIR` is by default `"/usr/share/libalpm/hooks/"` (defined by `-DSYSHOOKDIR=\"@datarootdir@/libalpm/hooks/\"` in `AM_CPPFLAGS`).
> 
> This means that the resulting `hookdir` is `"//usr/share/libalpm/hooks/"`, or `"/something/else//usr/share/libalpm/hooks/"` if `--root /something/else` is passed on command line.
> 
> If you need a reason for changing this (other than programmer's tidiness), know that this causes trouble in Cygwin/MSYS2 as paths starting with `//` have special meaning.
> 
> I can send a patch, but I'm not sure what's the best way to change it. How about
> 
> sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR + 1);
> 
> with a corresponding change in the allocation above it and a comment explaining the magic number? It seems that `root` will always end in a slash and `SYSHOOKDIR` will always start with one, so I picked the one easier to remove.
> 

That seems fine.  Adjust the malloc too.

A


More information about the pacman-dev mailing list