From: Dag-Erling Smørgrav Date: Wed, 24 Jun 2026 15:58:29 +0000 (+0200) Subject: libarchive: Fix format string issues X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db1bb73b86337dceef8eca022140b00821d4548f;p=thirdparty%2Flibarchive.git libarchive: Fix format string issues --- diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index 98bc4952d..4478ceb58 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -111,7 +111,7 @@ static int xml_writer_start_element(struct xml_writer *ctx, static int xml_writer_write_attribute(struct xml_writer *ctx, const char *key, const char *value); static int xml_writer_write_attributef(struct xml_writer *ctx, const char *key, - const char *format, ...); + const char *format, ...) __LA_PRINTF(3, 4); static int xml_writer_write_string(struct xml_writer *ctx, const char *string); static int xml_writer_write_base64(struct xml_writer* ctx, const char *data, size_t start, size_t len); @@ -907,7 +907,7 @@ xmlwrite_string(struct archive_write *a, struct xml_writer *writer, return (ARCHIVE_OK); } -static int +static int __LA_PRINTF(4, 5) xmlwrite_fstring(struct archive_write *a, struct xml_writer *writer, const char *key, const char *fmt, ...) { @@ -1333,11 +1333,11 @@ make_file_entry(struct archive_write *a, struct xml_writer *writer, return (ARCHIVE_FATAL); } r = xmlwrite_fstring(a, writer, "major", - "%d", archive_entry_rdevmajor(file->entry)); + "%ld", (long)archive_entry_rdevmajor(file->entry)); if (r < 0) return (ARCHIVE_FATAL); r = xmlwrite_fstring(a, writer, "minor", - "%d", archive_entry_rdevminor(file->entry)); + "%ld", (long)archive_entry_rdevminor(file->entry)); if (r < 0) return (ARCHIVE_FATAL); r = xml_writer_end_element(writer); @@ -1361,7 +1361,7 @@ make_file_entry(struct archive_write *a, struct xml_writer *writer, return (ARCHIVE_FATAL); if (archive_entry_dev(file->entry) != 0) { r = xmlwrite_fstring(a, writer, "deviceno", - "%d", archive_entry_dev(file->entry)); + "%ld", (long)archive_entry_dev(file->entry)); if (r < 0) return (ARCHIVE_FATAL); } diff --git a/libarchive/test/test_read_format_zip_zipx_encrypted.c b/libarchive/test/test_read_format_zip_zipx_encrypted.c index 5349ba199..f07e1e5c3 100644 --- a/libarchive/test/test_read_format_zip_zipx_encrypted.c +++ b/libarchive/test/test_read_format_zip_zipx_encrypted.c @@ -56,7 +56,7 @@ static la_ssize_t read_streaming_buffer(struct archive *a, void *_client_data, c } static void -validate_entry_read(struct archive *a, const char* msg, const int streaming_reader) +validate_entry_read(struct archive *a, const int streaming_reader) { struct archive_entry *ae; size_t total_read; @@ -76,7 +76,8 @@ validate_entry_read(struct archive *a, const char* msg, const int streaming_read r = archive_read_data(a, readbuf, sizeof(readbuf)); if (r <= 0) { if (r < 0) { - failure(msg, (int) r, archive_error_string(a)); + failure("archive_read_data returned %d: %s", + (int)r, archive_error_string(a)); assertEqualInt(r > 0, 1); } break; @@ -114,7 +115,7 @@ test_encrypted_zipx_read_mem(char* buff, size_t used) assertEqualIntA(a, ARCHIVE_OK, archive_read_add_passphrase(a, password)); assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used)); - validate_entry_read(a, "archive_read_data returned %d: %s", 0); + validate_entry_read(a, 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); @@ -126,7 +127,7 @@ test_encrypted_zipx_read_mem(char* buff, size_t used) assertEqualIntA(a, ARCHIVE_OK, archive_read_add_passphrase(a, password)); assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, buff, used, 7)); - validate_entry_read(a, "seek: archive_read_data returned %d: %s", 0); + validate_entry_read(a, 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); @@ -144,7 +145,7 @@ test_encrypted_zipx_read_callback(const char* buff, const size_t used) assertEqualIntA(a, ARCHIVE_OK, archive_read_add_passphrase(a, password)); /* NOTE: archive_read_open2 with read callback only -> NON-seekable. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_open2(a, &stream_buffer, NULL, read_streaming_buffer, NULL, NULL)); - validate_entry_read(a, "archive_read_data returned %d: %s", 1); + validate_entry_read(a, 1); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); }