]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire_path_join: Implicitely handle size argument
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Apr 2021 15:04:44 +0000 (15:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Apr 2021 15:04:44 +0000 (15:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/archive.c
src/libpakfire/execute.c
src/libpakfire/include/pakfire/util.h
src/libpakfire/key.c
src/libpakfire/pakfire.c
src/libpakfire/util.c

index bf00a58a15684971dadb125df74b6495e50a294b..8563252432b88786484271703b7f0bc5eedc2ebd 100644 (file)
@@ -770,7 +770,7 @@ PAKFIRE_EXPORT char* pakfire_archive_extraction_path(PakfireArchive archive, con
        char* nevra = pakfire_package_get_nevra(pkg);
 
        // Append package name and version to path
-       int r = pakfire_path_join(prefix, sizeof(prefix), target, nevra);
+       int r = pakfire_path_join(prefix, target, nevra);
 
        // Cleanup
        pakfire_package_unref(pkg);
@@ -821,7 +821,7 @@ static int pakfire_archive_extract_entry(PakfireArchive archive,
 
        // Prepend the prefix
        if (extractor->prefix) {
-               r = pakfire_path_join(buffer, sizeof(buffer) - 1, extractor->prefix, path);
+               r = pakfire_path_join(buffer, extractor->prefix, path);
                if (r < 0)
                        goto ERROR;
 
@@ -830,7 +830,7 @@ static int pakfire_archive_extract_entry(PakfireArchive archive,
                // Update hardlink destination
                const char* link = archive_entry_hardlink(entry);
                if (link) {
-                       r = pakfire_path_join(buffer, sizeof(buffer) - 1, extractor->prefix, link);
+                       r = pakfire_path_join(buffer, extractor->prefix, link);
                        if (r < 0)
                                goto ERROR;
 
index e5cba090816f67d03dcb5839e753b532b6471c52..c3db19a7163c9188a12e740e2e454fc46cf50fbf 100644 (file)
@@ -489,7 +489,7 @@ PAKFIRE_EXPORT int pakfire_execute_script(Pakfire pakfire, const char* script, c
        int r;
 
        // Write the scriptlet to disk
-       r = pakfire_path_join(path, sizeof(path) - 1, root, "tmp/.pakfire-script.XXXXXX");
+       r = pakfire_path_join(path, root, "tmp/.pakfire-script.XXXXXX");
        if (r < 0)
                goto out;
 
index 2acd086fa0b215390d74091c27131598ed170e32..9cca0834b78dfc9a8189c075ff7fa33f9c0e4ed1 100644 (file)
@@ -56,7 +56,10 @@ int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len);
 
 char* pakfire_hexlify(const char* digest, const size_t length);
 
-int pakfire_path_join(char* dest, size_t length,
+#define pakfire_path_join(dest, first, second) \
+       __pakfire_path_join(dest, sizeof(dest) - 1, first, second)
+
+int __pakfire_path_join(char* dest, size_t length,
        const char* first, const char* second);
 const char* pakfire_path_relpath(const char* root, const char* path);
 
index 08f47e4b88d800e8633529259f9902eefe29122e..64a16f7f25a211fca8da2aee78e3e283c296e6da 100644 (file)
@@ -68,7 +68,7 @@ gpgme_ctx_t pakfire_get_gpgctx(Pakfire pakfire) {
 
        // Use GPG
        const char* path = pakfire_get_path(pakfire);
-       int r = pakfire_path_join(home, sizeof(home) - 1, path, "etc/pakfire/gnupg");
+       int r = pakfire_path_join(home, path, "etc/pakfire/gnupg");
        if (r < 0)
                goto FAIL;
 
index 7a57c5d1ed4f1f568efea5889b9f9c70a9f9ae34..6e74f67f397e05b6ae1b8be343a884edb1b038df 100644 (file)
@@ -161,7 +161,7 @@ static int pakfire_mount(Pakfire pakfire) {
 
                DEBUG(pakfire, "Mounting /%s\n", mp->target);
 
-               r = pakfire_path_join(target, sizeof(target) - 1, pakfire->path, mp->target);
+               r = pakfire_path_join(target, pakfire->path, mp->target);
                if (r < 0)
                        return r;
 
@@ -785,7 +785,7 @@ PAKFIRE_EXPORT char* pakfire_make_path(Pakfire pakfire, const char* path) {
        while (path && *path == '/')
                path++;
 
-       int r = pakfire_path_join(buffer, sizeof(buffer) - 1, pakfire->path, path);
+       int r = pakfire_path_join(buffer, pakfire->path, path);
        if (r < 0)
                return NULL;
 
index 3982b0a1e932ff5b749261c811e268b193536ca3..95a7e82171e839a306b24711ea2c9ccd93b342b6 100644 (file)
@@ -286,7 +286,7 @@ char* pakfire_format_date(time_t t) {
        return pakfire_strftime("%Y-%m-%d", t);
 }
 
-int pakfire_path_join(char* dest, size_t length,
+int __pakfire_path_join(char* dest, size_t length,
                const char* first, const char* second) {
        if (!second)
                return snprintf(dest, length, "%s", first);