[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives
From: |
Radek Brich |
Subject: |
Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives |
Date: |
Wed, 12 Dec 2007 13:53:20 +0100 |
User-agent: |
KMail/1.9.6 (enterprise 0.20071012.724442) |
On Wed 12. of December 2007 12:08:43 Jim Meyering wrote:
> Radek Brich <address@hidden> wrote:
> > On Tue 11. of December 2007 13:55:53 you wrote:
> >> Radek Brich <address@hidden> ha escrit:
> >> > Although it'd need some cleaning, I'd like to hear what
> >> > you think about the idea?
> >>
> >> Generally speaking, looks nice, except that fstat may fail (e.g. if
> >> stdout is closed) in which case st_stdout would contain garbage.
>
> ...
>
> > + struct stat st_buf;
> > + ino_t stdout_ino = fstat(STDOUT_FILENO, &st_buf) == -1 ?
> > + 0 : st_buf.st_ino;
> > + ino_t archive_ino = stat(archive_name_array[0], &st_buf) == -1 ?
> > + 0 : st_buf.st_ino;
> > + bool archive_is_stdout = (archive_ino != 0 && archive_ino ==
> > stdout_ino);
>
> You'll want to compare st_dev, as well.
> Otherwise, there's a small risk of a false positive with
> a file on a different partition, but with the same inode number.
>
> You can use the SAME_INODE macro from gnulib's lib/same-inode.h,
> since tar already has that file.
Yes, thanks, you are right.
I also tried to make it look less alien in the rest of the code.
--
Radek Brich
/__\ Base OS/core services
~~~~~~~~ Red Hat, Brno, Czech Rep.
tar-1.19-stderrlist.patch
Description: Text Data
signature.asc
Description: This is a digitally signed message part.
Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Radek Brich, 2007/12/11
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Sergey Poznyakoff, 2007/12/11
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Radek Brich, 2007/12/11
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Radek Brich, 2007/12/11
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Jim Meyering, 2007/12/12
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives,
Radek Brich <=
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Radek Brich, 2007/12/12
- Re: [Bug-tar] tar -vf /dev/stdout produces corrupted archives, Paul Eggert, 2007/12/17