From 3a9f00c59bad7735970c72cb940d08161fda09b0 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 6 Sep 2021 03:28:46 +0430 Subject: Everywhere: Use OOM-safe ByteBuffer APIs where possible If we can easily communicate failure, let's avoid asserting and report failure instead. --- Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibCrypto/PK') diff --git a/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h b/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h index 2b5e89c1a2..1f99484d9d 100644 --- a/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h +++ b/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h @@ -151,7 +151,10 @@ public: for (size_t counter = 0; counter < length / HashFunction::DigestSize - 1; ++counter) { hash_fn.update(seed); hash_fn.update((u8*)&counter, 4); - T.append(hash_fn.digest().data, HashFunction::DigestSize); + if (!T.try_append(hash_fn.digest().data, HashFunction::DigestSize)) { + dbgln("EMSA_PSS: MGF1 digest failed, not enough space"); + return; + } } out.overwrite(0, T.data(), length); } -- cgit v1.2.3