Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Sep 1998 19:41:20 -0500 (CDT)
From:      Erik E Rantapaa <rantapaa@uswest.net>
To:        freebsd-ports@FreeBSD.ORG
Subject:   some bugs in cpio 
Message-ID:  <Pine.BSF.3.91.980929194106.14261A-200000@tahiti.oss.uswest.net>

next in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-781779665-907114549=:10556
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.BSF.3.91.980929194106.14261C@tahiti.oss.uswest.net>

Hello Freebsd-ers...

I fixed a few bugs in cpio-2.4.2 and have just sent a bug report to the GNU
folks.  I also thought I would report them here since FreeBSD uses GNU cpio
as part of its base system.

If there is a better way to report these kind of things, please let me know
and I'll note it for future reference.

Cheers,

Erik Rantapaa
rantapaa@uswest.net

---------- Forwarded message ----------
Date: Tue, 29 Sep 1998 19:15:49 -0500 (CDT)
From: Erik E Rantapaa <rantapaa@tahiti.oss.uswest.net>
To: bug-gnu-utils@prep.ai.mit.edu
Subject: some bugs in cpio

Hello,

Here are some bugs I found in cpio-2.4.2.  I have tested the fix for
bug #1 and it seems to work. I have not run into bug #2 yet, so the
fix I have for that is more speculative, although I'm pretty sure it is
the right thing to do.

A patch file is included.

--
Erik Rantapaa
rantapaa@uswest.net


Bug #1: cpio writes corrupted archives when archiving growing files

Description:

If a file that cpio is archiving grows in size during the archiving process, 
the growth will appear as part of the next file placed into the archive.
This results in a corrupted archive.

The problem is that that cpio is not resetting its input buffer when
it opens a new file.

Fix:

Reset the input buffer by setting input_size = 0 in a few places
-- specifically whenever a new file is designated to be the one
that uses the input buffer.

Bug #2: cpio may not handle file shrinkage properly

Description:

>From the code it appears that cpio may not handle files which shrink
during the archiving process in the most desirable way.  The code
attempts to pad the missing content with nulls.  However, those nulls
are written to the file descriptor directly with write(), whereas normally 
file data is written through a buffer.  This could result in the nulls
being placed somewhere in the middle of the file instead of at the end
where it would make more sense for them to be.

Fix:

Call disk_empty_output_buffer() / tape_empty_output_buffer() (whichever
is appropriate) before calling write_nuls_to_file().
--0-781779665-907114549=:10556
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME=cpio-patches
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSF.3.91.980929191549.10556B@tahiti.oss.uswest.net>
Content-Description: patches to cpio-2.4.2

ZGlmZiAtdSBjcGlvLTIuNC4yL2NvcHlvdXQuYyBjcGlvLTIuNC4yLWZpeGVk
L2NvcHlvdXQuYw0KLS0tIGNwaW8tMi40LjIvY29weW91dC5jCVdlZCBKYW4g
MTAgMTA6MTA6NDUgMTk5Ng0KKysrIGNwaW8tMi40LjItZml4ZWQvY29weW91
dC5jCVR1ZSBTZXAgMjkgMTg6MzU6NTAgMTk5OA0KQEAgLTM2OSw2ICszNjks
NyBAQA0KIAkJICAgIH0NCiAJCX0NCiAjZW5kaWYNCisJICAgICAgaW5wdXRf
c2l6ZSA9IDA7DQogCSAgICAgIGluX2ZpbGVfZGVzID0gb3BlbiAoaW5wdXRf
bmFtZS5kc19zdHJpbmcsDQogCQkJCSAgT19SRE9OTFkgfCBPX0JJTkFSWSwg
MCk7DQogCSAgICAgIGlmIChpbl9maWxlX2RlcyA8IDApDQpAQCAtNzcwLDYg
Kzc3MSw3IEBADQogICBmaWxlX2hkciA9ICpoZWFkZXI7DQogDQogDQorICBp
bnB1dF9zaXplID0gMDsNCiAgIGluX2ZpbGVfZGVzID0gb3BlbiAoaGVhZGVy
LT5jX25hbWUsDQogCQkgICAgICBPX1JET05MWSB8IE9fQklOQVJZLCAwKTsN
CiAgIGlmIChpbl9maWxlX2RlcyA8IDApDQpPbmx5IGluIGNwaW8tMi40LjIt
Zml4ZWQ6IGNvcHlvdXQubw0KZGlmZiAtdSBjcGlvLTIuNC4yL2NvcHlwYXNz
LmMgY3Bpby0yLjQuMi1maXhlZC9jb3B5cGFzcy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pAQCAtNTQ0LDYgKzU0NSw3IEBADQogCSAgICBlbHNlDQog
CSAgICAgIGVycm9yICgwLCAwLCAiUmVhZCBlcnJvciBhdCBieXRlICVsZCBp
biBmaWxlICVzLCBwYWRkaW5nIHdpdGggemVyb3MiLA0KIAkJCW9yaWdpbmFs
X251bV9ieXRlcyAtIG51bV9ieXRlcywgZmlsZW5hbWUpOw0KKwkgICAgZGlz
a19lbXB0eV9vdXRwdXRfYnVmZmVyKG91dF9kZXMpOw0KIAkgICAgd3JpdGVf
bnVsc190b19maWxlIChudW1fYnl0ZXMsIG91dF9kZXMpOw0KIAkgICAgYnJl
YWs7DQogCSAgfQ0K
--0-781779665-907114549=:10556--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.980929194106.14261A-200000>