From 1bbd2900de129fb9b712a0324c279ccc99d42f27 Mon Sep 17 00:00:00 2001 From: lindexi Date: Fri, 20 Jun 2025 16:00:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E8=80=83=E5=8F=A4=E6=B3=A8=E9=87=8A=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DebUOS/Packaging.Targets/IO/TarHeader.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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++) From 964acb356eaaf77159007f195f2122ac66f9c3e1 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 23 Jun 2025 09:49:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DebUOS/Packaging.Targets/IO/TarHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DebUOS/Packaging.Targets/IO/TarHeader.cs b/DebUOS/Packaging.Targets/IO/TarHeader.cs index 95ce7f4..9e41586 100644 --- a/DebUOS/Packaging.Targets/IO/TarHeader.cs +++ b/DebUOS/Packaging.Targets/IO/TarHeader.cs @@ -71,7 +71,7 @@ public string FileName 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."; + private const string TarLimitReason = "From https://www.gnu.org/software/tar/manual/html_node/Standard.html , The file name (or leaf) length cannot exceed 100 characters. It is the limit of tar."; public LinuxFileMode FileMode { From fd65286588b297415b53e0feba632b17c44f97b1 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 23 Jun 2025 10:00:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=86=85=E5=AE=B9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 964acb356eaaf77159007f195f2122ac66f9c3e1. --- DebUOS/Packaging.Targets/IO/TarHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DebUOS/Packaging.Targets/IO/TarHeader.cs b/DebUOS/Packaging.Targets/IO/TarHeader.cs index 9e41586..95ce7f4 100644 --- a/DebUOS/Packaging.Targets/IO/TarHeader.cs +++ b/DebUOS/Packaging.Targets/IO/TarHeader.cs @@ -71,7 +71,7 @@ public string FileName set => this.name = this.CreateString(value, 100, reason: TarLimitReason); } - private const string TarLimitReason = "From https://www.gnu.org/software/tar/manual/html_node/Standard.html , The file name (or leaf) length cannot exceed 100 characters. It is the limit of tar."; + 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 {