From a38e42fe5461224fa4ee34714793ff0e62b7fd28 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Mon, 13 Feb 2023 16:53:18 +0100 Subject: [PATCH 1/2] System.Console: allow terminfo files to be larger than 4KiB. --- .../System.Console/src/System/TermInfo.DatabaseFactory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs b/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs index 0db908b2729bbd..142fce7a862e19 100644 --- a/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs +++ b/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs @@ -107,7 +107,9 @@ private static bool TryOpen(string filePath, [NotNullWhen(true)] out SafeFileHan { // Read in all of the terminfo data long termInfoLength = RandomAccess.GetLength(fd); - const int MaxTermInfoLength = 4096; // according to the term and tic man pages, 4096 is the terminfo file size max + // according to the term and tic man pages, 4096 is the terminfo file size max + // Fedora includes terminfo files that are slightly larger than 4096. + const int MaxTermInfoLength = 8096; const int HeaderLength = 12; if (termInfoLength <= HeaderLength || termInfoLength > MaxTermInfoLength) { From 5cba8ffa5679e376f641f42e833e8eaba5066efd Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Tue, 14 Feb 2023 07:33:28 +0100 Subject: [PATCH 2/2] Remove file size check. --- .../System.Console/src/System/TermInfo.DatabaseFactory.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs b/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs index 142fce7a862e19..4f73885d1db662 100644 --- a/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs +++ b/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs @@ -107,11 +107,8 @@ private static bool TryOpen(string filePath, [NotNullWhen(true)] out SafeFileHan { // Read in all of the terminfo data long termInfoLength = RandomAccess.GetLength(fd); - // according to the term and tic man pages, 4096 is the terminfo file size max - // Fedora includes terminfo files that are slightly larger than 4096. - const int MaxTermInfoLength = 8096; const int HeaderLength = 12; - if (termInfoLength <= HeaderLength || termInfoLength > MaxTermInfoLength) + if (termInfoLength <= HeaderLength) { throw new InvalidOperationException(SR.IO_TermInfoInvalid); }