Skip to content

Commit

Permalink
Fix format strings (libarchive#2457)
Browse files Browse the repository at this point in the history
(cherry picked from commit a659a44)
  • Loading branch information
gperciva authored and mmatuska committed Dec 29, 2024
1 parent f4f9ec8 commit 80649a2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cpio/cpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
else
strcpy(date, "invalid mtime");

fprintf(out, "%s%3d %-8s %-8s %8s %12s %s",
fprintf(out, "%s%3u %-8s %-8s %8s %12s %s",
archive_entry_strmode(entry),
archive_entry_nlink(entry),
uname, gname, size, date,
Expand Down
6 changes: 3 additions & 3 deletions libarchive/archive_read_support_format_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2134,15 +2134,15 @@ zipx_ppmd8_init(struct archive_read *a, struct zip *zip)

if(order < 2 || restore_method > 2) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Invalid parameter set in PPMd8 stream (order=%" PRId32 ", "
"restore=%" PRId32 ")", order, restore_method);
"Invalid parameter set in PPMd8 stream (order=%" PRIu32 ", "
"restore=%" PRIu32 ")", order, restore_method);
return (ARCHIVE_FAILED);
}

/* Allocate the memory needed to properly decompress the file. */
if(!__archive_ppmd8_functions.Ppmd8_Alloc(&zip->ppmd8, mem << 20)) {
archive_set_error(&a->archive, ENOMEM,
"Unable to allocate memory for PPMd8 stream: %" PRId32 " bytes",
"Unable to allocate memory for PPMd8 stream: %" PRIu32 " bytes",
mem << 20);
return (ARCHIVE_FATAL);
}
Expand Down
8 changes: 4 additions & 4 deletions libarchive/test/test_write_disk_perms.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ DEFINE_TEST(test_write_disk_perms)

/* Check original owner. */
assertEqualInt(0, stat("dir_owner", &st));
failure("dir_owner: st.st_uid=%d", st.st_uid);
failure("dir_owner: st.st_uid=%jd", (intmax_t)st.st_uid);
assertEqualInt(st.st_uid, original_uid);
/* Shouldn't try to edit the owner when no overwrite option is set. */
assert((ae = archive_entry_new()) != NULL);
Expand All @@ -230,7 +230,7 @@ DEFINE_TEST(test_write_disk_perms)
assertEqualIntA(a, ARCHIVE_OK, archive_write_finish_entry(a));
/* Make sure they're unchanged. */
assertEqualInt(0, stat("dir_owner", &st));
failure("dir_owner: st.st_uid=%d", st.st_uid);
failure("dir_owner: st.st_uid=%jd", (intmax_t)st.st_uid);
assertEqualInt(st.st_uid, original_uid);

/* Write a regular file with SUID bit, but don't use _EXTRACT_PERM. */
Expand Down Expand Up @@ -475,8 +475,8 @@ DEFINE_TEST(test_write_disk_perms)
assertEqualInt(0, stat("file_bad_owner", &st));
failure("file_bad_owner: st.st_mode=%o", st.st_mode);
assertEqualInt(st.st_mode & 07777, 0744);
failure("file_bad_owner: st.st_uid=%d getuid()=%d",
st.st_uid, getuid());
failure("file_bad_owner: st.st_uid=%jd getuid()=%jd",
(intmax_t)st.st_uid, (intmax_t)getuid());
/* The entry had getuid()+1, but because we're
* not root, we should not have been able to set that. */
assertEqualInt(st.st_uid, getuid());
Expand Down
2 changes: 1 addition & 1 deletion tar/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
}
if (!now)
time(&now);
fprintf(out, "%s %d ",
fprintf(out, "%s %u ",
archive_entry_strmode(entry),
archive_entry_nlink(entry));

Expand Down
2 changes: 1 addition & 1 deletion test_utils/test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3536,7 +3536,7 @@ test_summarize(int failed, int skips_num)

for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
if (failed_lines[i].count > 1 && !failed_lines[i].skip)
logprintf("%s:%d: Summary: Failed %d times\n",
logprintf("%s:%u: Summary: Failed %d times\n",
failed_filename, i, failed_lines[i].count);
}
/* Clear the failure history for the next file. */
Expand Down

0 comments on commit 80649a2

Please sign in to comment.