summaryrefslogtreecommitdiff
path: root/lib/tar/write_header.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-07-09 18:06:53 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-07-09 20:00:36 +0200
commit270fac93b9bdc2da16126817d48ce109ef9073bb (patch)
tree62ad8a4d0bf74f757e8483e49b46c2a26a38de7b /lib/tar/write_header.c
parentfaef7494d60ce9a120629d7544f03cdd89800132 (diff)
Fix printf format specifiers used for generating tarballs
When processing files > 4G, using "%o" truncates the result and the tarball is not readable. This should have been discovered when auto-patching the printf format specifiers, but a cast was added instead and the issue was overlooked. This commit replaces the down-cast and printf format specifiers. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/write_header.c')
-rw-r--r--lib/tar/write_header.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/tar/write_header.c b/lib/tar/write_header.c
index aaf9f08..418e602 100644
--- a/lib/tar/write_header.c
+++ b/lib/tar/write_header.c
@@ -31,10 +31,10 @@ static void write_number(char *dst, sqfs_u64 value, int digits)
mask = (mask << 3) | 7;
if (value <= mask) {
- sprintf(buffer, "%0*o ", digits - 1, (unsigned int)value);
+ sprintf(buffer, "%0*lo ", digits - 1, (unsigned long)value);
memcpy(dst, buffer, digits);
} else if (value <= ((mask << 3) | 7)) {
- sprintf(buffer, "%0*o", digits, (unsigned int)value);
+ sprintf(buffer, "%0*lo", digits, (unsigned long)value);
memcpy(dst, buffer, digits);
} else {
write_binary(dst, value, digits);