mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8280703: CipherCore.doFinal(...) causes potentially massive byte[] allocations during decryption
Reviewed-by: ascarpino
This commit is contained in:
parent
cb8a82ee24
commit
409382ba4b
1 changed files with 8 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -812,10 +812,13 @@ final class CipherCore {
|
|||
if (outputCapacity < estOutSize) {
|
||||
cipher.save();
|
||||
}
|
||||
// create temporary output buffer if the estimated size is larger
|
||||
// than the user-provided buffer.
|
||||
internalOutput = new byte[estOutSize];
|
||||
offset = 0;
|
||||
if (outputCapacity < estOutSize || padding != null) {
|
||||
// create temporary output buffer if the estimated size is larger
|
||||
// than the user-provided buffer or a padding needs to be removed
|
||||
// before copying the unpadded result to the output buffer
|
||||
internalOutput = new byte[estOutSize];
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] outBuffer = (internalOutput != null) ? internalOutput : output;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue