Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8280703: CipherCore.doFinal(...) causes potentially massive byte[] al…
…locations during decryption

Backport-of: 409382ba4b43bf48ed0086020dd20641effd35b6
  • Loading branch information
Scott Gibbons authored and RealCLanger committed Feb 24, 2023
1 parent 53caaf5 commit 9c35d59
Showing 1 changed file 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
Expand Down Expand Up @@ -813,10 +813,13 @@ int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output,
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;
Expand Down

1 comment on commit 9c35d59

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.