Signed-off-by: Allan McRae <[email protected]>
---
 lib/libalpm/trans.c | 4 ++--
 lib/libalpm/util.c  | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index e4c8e404..50d80866 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -358,9 +358,9 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char 
*filepath,
        }
 
        /* either extract or copy the scriptlet */
-       len += strlen("/.INSTALL");
+       len += strlen(".INSTALL");
        MALLOC(scriptfn, len, free(tmpdir); RET_ERR(handle, ALPM_ERR_MEMORY, 
-1));
-       snprintf(scriptfn, len, "%s/.INSTALL", tmpdir);
+       snprintf(scriptfn, len, "%s.INSTALL", tmpdir);
        if(is_archive) {
                if(_alpm_unpack_single(handle, filepath, tmpdir, ".INSTALL")) {
                        retval = 1;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 514681d1..dacabdad 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -154,9 +154,10 @@ int _alpm_mkdtemp(alpm_handle_t *handle, char **tmpdir)
 
        ASSERT(tmpdir != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, 0));
 
-       len = strlen(handle->root) + strlen("tmp/alpm_XXXXXX") + 1;
+       len = strlen(handle->root) + strlen("tmp/alpm_XXXXXX/") + 1;
        MALLOC(*tmpdir, len, RET_ERR(handle, ALPM_ERR_MEMORY, 0));
        snprintf(*tmpdir, len, "%stmp/", handle->root);
+
        if(access(*tmpdir, F_OK) != 0) {
                _alpm_makepath_mode(*tmpdir, 01777);
        }
@@ -167,6 +168,9 @@ int _alpm_mkdtemp(alpm_handle_t *handle, char **tmpdir)
                return 0;
        }
 
+       (*tmpdir)[len - 2] = '/';
+       (*tmpdir)[len - 1] = '\0';
+
        return len;
 }
 
-- 
2.24.1

Reply via email to