From 71f9de64c6eaf11e22551de56d4e9233dddfe238 Mon Sep 17 00:00:00 2001 From: David Macek Date: Sun, 29 Nov 2015 14:55:15 +0100 Subject: 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 --- lib/libalpm/alpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 0798c0bc..54dfade2 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -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 */ -- cgit v1.2.3-24-g4f1b