diff --git a/DebUOS/Packaging.Targets/IO/TarHeader.cs b/DebUOS/Packaging.Targets/IO/TarHeader.cs index ca9bde8..95ce7f4 100644 --- a/DebUOS/Packaging.Targets/IO/TarHeader.cs +++ b/DebUOS/Packaging.Targets/IO/TarHeader.cs @@ -68,9 +68,11 @@ internal unsafe struct TarHeader : IArchiveHeader public string FileName { get => this.GetString(this.name, 100); - set => this.name = this.CreateString(value, 100); + set => this.name = this.CreateString(value, 100, reason: TarLimitReason); } + private const string TarLimitReason = "From http://ibgwww.colorado.edu/~lessem/psyc5112/usail/man/solaris/tar.1.html , The file name (or leaf) length cannot exceed 100 characters. It is the limit of tar."; + public LinuxFileMode FileMode { get => (LinuxFileMode)Convert.ToUInt32(this.GetString(this.mode, 8), 8); @@ -124,7 +126,7 @@ public TarTypeFlag TypeFlag public string LinkName { get => this.GetString(this.linkname, 100); - set => this.linkname = this.CreateString(value, 100); + set => this.linkname = this.CreateString(value, 100, TarLimitReason); } public string Magic @@ -242,7 +244,8 @@ private byte[] GetUIntTo8(uint? data, int len = 8) return this.CreateString(Convert.ToString(data.Value, 8).PadLeft(len - 1, '0'), len); } - private byte[] CreateString(string s, int len) +#nullable enable + private byte[] CreateString(string? s, int len, string? reason = null) { var target = new byte[len]; if (s == null) @@ -253,7 +256,7 @@ private byte[] CreateString(string s, int len) var buffer = Encoding.UTF8.GetBytes(s); if (buffer.Length > len) { - throw new Exception($"String {s} exceeds the limit of {len}"); + throw new Exception($"String {s} exceeds the limit of {len}.{reason}"); } for (var c = 0; c < len; c++)