From 2f5332f20a975a7ad9961451a0a18930f6e1be85 Mon Sep 17 00:00:00 2001 From: Angelina Pavlovets Date: Wed, 10 Jul 2024 14:16:48 +0000 Subject: [PATCH] Make cipher field in AESCipher and AESCipherCBCnoPad thread safe DEVSIX-8435 Autoported commit. Original commit hash: [cecbc2716] Manual files: kernel/src/main/java/com/itextpdf/kernel/crypto/AESCipher.java kernel/src/main/java/com/itextpdf/kernel/crypto/AESCipherCBCnoPad.java kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/EncryptionUtils.java sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidationProperties.java --- itext/itext.kernel/itext/kernel/crypto/AESCipherCBCnoPad.cs | 2 +- itext/itext.kernel/itext/kernel/pdf/PdfNumTree.cs | 6 +++--- itext/itext.kernel/itext/kernel/pdf/PdfWriter.cs | 2 +- .../itext/signatures/validation/v1/SafeCalling.cs | 4 ++-- port-hash | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/itext/itext.kernel/itext/kernel/crypto/AESCipherCBCnoPad.cs b/itext/itext.kernel/itext/kernel/crypto/AESCipherCBCnoPad.cs index 6dd929ed1d..45abadfa68 100644 --- a/itext/itext.kernel/itext/kernel/crypto/AESCipherCBCnoPad.cs +++ b/itext/itext.kernel/itext/kernel/crypto/AESCipherCBCnoPad.cs @@ -26,7 +26,7 @@ You should have received a copy of the GNU Affero General Public License namespace iText.Kernel.Crypto { /// Creates an AES Cipher with CBC and no padding. public class AESCipherCBCnoPad { - private static ICipherCBCnoPad cipher; + private ICipherCBCnoPad cipher; /// Creates a new instance of AESCipher with CBC and no padding /// diff --git a/itext/itext.kernel/itext/kernel/pdf/PdfNumTree.cs b/itext/itext.kernel/itext/kernel/pdf/PdfNumTree.cs index 91270561ff..e410040315 100644 --- a/itext/itext.kernel/itext/kernel/pdf/PdfNumTree.cs +++ b/itext/itext.kernel/itext/kernel/pdf/PdfNumTree.cs @@ -75,9 +75,9 @@ public virtual PdfDictionary BuildTree() { if (numbers.Length <= NODE_SIZE) { PdfDictionary dic = new PdfDictionary(); PdfArray ar = new PdfArray(); - for (int k = 0; k < numbers.Length; ++k) { - ar.Add(new PdfNumber((int)numbers[k])); - ar.Add(items.Get(numbers[k])); + foreach (int? number in numbers) { + ar.Add(new PdfNumber((int)number)); + ar.Add(items.Get(number)); } dic.Put(PdfName.Nums, ar); return dic; diff --git a/itext/itext.kernel/itext/kernel/pdf/PdfWriter.cs b/itext/itext.kernel/itext/kernel/pdf/PdfWriter.cs index bf7b14be30..a109520257 100644 --- a/itext/itext.kernel/itext/kernel/pdf/PdfWriter.cs +++ b/itext/itext.kernel/itext/kernel/pdf/PdfWriter.cs @@ -94,7 +94,7 @@ public PdfWriter(String filename, WriterProperties properties) /// Indicates if to use full compression mode. /// true if to use full compression, false otherwise. public virtual bool IsFullCompression() { - return properties.isFullCompression != null ? (bool)properties.isFullCompression : false; + return properties.isFullCompression != null && (bool)properties.isFullCompression; } /// Gets default compression level for @see PdfStream. diff --git a/itext/itext.sign/itext/signatures/validation/v1/SafeCalling.cs b/itext/itext.sign/itext/signatures/validation/v1/SafeCalling.cs index e15e8f0114..12c8b294bb 100644 --- a/itext/itext.sign/itext/signatures/validation/v1/SafeCalling.cs +++ b/itext/itext.sign/itext/signatures/validation/v1/SafeCalling.cs @@ -48,8 +48,8 @@ public static void OnExceptionLog(Action action, ValidationReport report, FuncThe value to return when an exception is thrown /// The report to add the ReportItem to /// A callback to generate a ReportItem - /// The returned value from the action /// + /// The returned value from the action public static T OnExceptionLog(Func action, T defaultValue, ValidationReport report, Func reportItemCreator) { try { @@ -80,8 +80,8 @@ public static void OnRuntimeExceptionLog(Action action, ValidationReport report, /// The value to return when an exception is thrown /// The report to add the ReportItem to /// A callback to generate a ReportItem - /// The returned value from the action /// + /// The returned value from the action public static T OnRuntimeExceptionLog(Func action, T defaultValue, ValidationReport report, Func reportItemCreator) { try { diff --git a/port-hash b/port-hash index 0bd73f67c3..fa3a5ad64e 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -5a8f86d5e1ee424e95f9bae23d0ae30f8a971989 +cecbc27166eb8d323051127a3436131ba4993639