bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Missing O_TRUNC flag in rmtcreat()


From: Matteo Croce
Subject: Missing O_TRUNC flag in rmtcreat()
Date: Mon, 4 Nov 2024 01:49:13 +0100

I don't know the paxutils mailing list address, so I'll send here
because tar is a paxutils user.
I'll report the issue here, if it's a problem, kindly point me to the
right address.

In paxutils, commit cd720d0fdcbd changed rmtcreat() to use rmtopen()
instead of creat(), but doesn't pass the O_TRUNC flag.
This means that tar would not truncate an existing archive, if the
file already exists:

$ dd if=/dev/zero of=test.tar bs=100k count=1
1+0 records in
1+0 records out
102400 bytes (102 kB, 100 KiB) copied, 0.000390167 s, 262 MB/s

$ ll README test.tar
-rw-r--r--. 1 matteo matteo 9.6K Oct 31 00:18 README
-rw-r--r--. 1 matteo matteo 100K Nov  4 01:33 test.tar

$ src/tar -c -f test.tar README

$ ll test.tar
-rw-r--r--. 1 matteo matteo 100K Nov  4 01:33 test.tar

$ file test.tar
test.tar: POSIX tar archive (GNU)

$ tar vtf test.tar
-rw-r--r-- matteo/matteo 9756 2024-10-31 00:18 README

Pass the flag fixes it:

$ ll test.tar
-rw-r--r--. 1 matteo matteo 100K Nov  4 01:33 test.tar

$ src/tar -c -f test.tar README

$ ll test.tar
-rw-r--r--. 1 matteo matteo 20K Nov  4 01:40 test.tar

Regards,
-- 
Matteo Croce

perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplay

Attachment: 0001-Missing-O_TRUNC-flag-in-rmtcreat.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]