bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] BUG: segfault with tar --index-file=bad_path


From: Khanh-Dang Nguyen Thu Lam
Subject: [Bug-tar] BUG: segfault with tar --index-file=bad_path
Date: Tue, 10 Jan 2012 20:46:05 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hello,


I am able to reproduce a bug in GNU tar (version 1.2.6 and 1.2.3-debian).  One
just have to use a valid archive, say valid.tar, and do:

$ tar -tf valid.tar --index-file=bad_path

The filename bad_path must point to a file you cannot open in write mode,
for example /foo if you don't have permission to write into /.

I have looked at the source code and the problem stems from
decode_options() in tar.c:

  if (index_file_name)
    {
      stdlis = fopen (index_file_name, "w");
      if (! stdlis)
        open_error (index_file_name);
    }

What happens is that stdlis is still set to NULL so that any fprintf(stdlis,
...) triggers a segfault.  I think the best behavior is to exit cleanly after
the call to open_error, with a non-zero exit code.


PS: I have not subscribed to this list, so please Cc me if you want me to read
your answer.



reply via email to

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