1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

alpm_initialize: Fix double slash in sys hook dir path

The path of the default system hook directory was created
by concatenating `myhandle->root` (usually "/"), and
SYSHOOKDIR (usually "/usr/share/libalpm/hooks/"), resulting
in "//usr/share/libalpm/hooks/". Fix this by skipping the
initial slash from SYSHOOKDIR.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
David Macek 2015-11-29 14:55:15 +01:00 committed by Allan McRae
parent 8ee084dbb3
commit 71f9de64c6

View File

@ -65,8 +65,11 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
goto cleanup;
}
MALLOC(hookdir, strlen(myhandle->root) + strlen(SYSHOOKDIR) + 1, goto cleanup);
sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR);
/* to contatenate myhandle->root (ends with a slash) with SYSHOOKDIR (starts
* with a slash) correctly, we skip SYSHOOKDIR[0]; the regular +1 therefore
* disappears from the allocation */
MALLOC(hookdir, strlen(myhandle->root) + strlen(SYSHOOKDIR), goto cleanup);
sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR + 1);
myhandle->hookdirs = alpm_list_add(NULL, hookdir);
/* set default database extension */