tobiasschulz / tar-cs

Automatically exported from code.google.com/p/tar-cs
Other
0 stars 0 forks source link

Invalid timestamp format #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
According to the specifaction

http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5&manpath=FreeBSD+8-current

modification time (mtime) must be an octal number of seconds since epoch.

The existing code does not convert the difference to octal number.

Original issue reported on code.google.com by tpgalche...@gmail.com on 2 May 2012 at 9:35

GoogleCodeExporter commented 9 years ago
recommended fix will be in the TarHeader.cs:

 public string LastModificationString
        {
            get
            {
                long ts = (long) (LastModification.ToUniversalTime() - TheEpoch).TotalSeconds;
                return AddChars(Convert.ToString(ts, 8), 11, '0', true);
            }
        }

Original comment by tpgalche...@gmail.com on 2 May 2012 at 9:36

GoogleCodeExporter commented 9 years ago
another recommended fix - in TarHeader.cs:

Octal is indeed the issue

in method: UpdateHeaderFromBytes
change:
long unixTimeStamp = Convert.ToInt64(Encoding.ASCII.GetString(buffer,136,11));
to:
long unixTimeStamp = Convert.ToInt64(Encoding.ASCII.GetString(buffer,136,11), 
8);

Original comment by sybrand....@gmail.com on 20 Jun 2012 at 10:19

GoogleCodeExporter commented 9 years ago

Original comment by vasilt...@gmail.com on 18 Jan 2014 at 11:48