From: Michael Tremer Date: Sat, 12 Oct 2024 19:16:23 +0000 (+0000) Subject: xfer: Only copy the URL once X-Git-Tag: 0.9.30~1051 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d69547c8f53624bbdabd876a085fcdafc7bc0f24;p=pakfire.git xfer: Only copy the URL once Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/string.h b/src/libpakfire/include/pakfire/string.h index b1aa2ae25..6b21dc3f7 100644 --- a/src/libpakfire/include/pakfire/string.h +++ b/src/libpakfire/include/pakfire/string.h @@ -34,6 +34,9 @@ __pakfire_string_format(s, sizeof(s), format, __VA_ARGS__) int __pakfire_string_format(char* s, const size_t length, const char* format, ...) __attribute__((format(printf, 3, 4))); + +#define pakfire_string_vformat(s, format, args) \ + __pakfire_string_vformat(s, sizeof(s), format, args) int __pakfire_string_vformat(char* s, const size_t length, const char* format, va_list args) __attribute__((format(printf, 3, 0))); diff --git a/src/libpakfire/xfer.c b/src/libpakfire/xfer.c index 4f4b0c932..beb12f307 100644 --- a/src/libpakfire/xfer.c +++ b/src/libpakfire/xfer.c @@ -343,7 +343,6 @@ ERROR: int pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx, const char* url, va_list args) { struct pakfire_xfer* x = NULL; - char buffer[PATH_MAX]; int r; // Fail if the context is flagged as offline @@ -352,11 +351,6 @@ int pakfire_xfer_create(struct pakfire_xfer** xfer, return -EPERM; } - // Format the URL - r = __pakfire_string_vformat(buffer, sizeof(buffer), url, args); - if (r < 0) - return r; - // Allocate a new xfer x = calloc(1, sizeof(*x)); if (!x) @@ -369,7 +363,7 @@ int pakfire_xfer_create(struct pakfire_xfer** xfer, x->nrefs = 1; // Store the URL - r = pakfire_string_set(x->url, buffer); + r = pakfire_string_vformat(x->url, url, args); if (r) goto ERROR;