mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:27:45 +00:00
Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report failure instead.
This commit is contained in:
parent
6606993432
commit
3a9f00c59b
22 changed files with 135 additions and 67 deletions
|
@ -35,7 +35,10 @@ ByteBuffer decode_pem(ReadonlyBytes data)
|
|||
break;
|
||||
}
|
||||
auto b64decoded = decode_base64(lexer.consume_line().trim_whitespace(TrimMode::Right));
|
||||
decoded.append(b64decoded.data(), b64decoded.size());
|
||||
if (!decoded.try_append(b64decoded.data(), b64decoded.size())) {
|
||||
dbgln("Failed to decode PEM, likely OOM condition");
|
||||
return {};
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Ended:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue