diff options
author | Nick Hudson <nick.hudson@isode.com> | 2015-03-24 16:56:21 (GMT) |
---|---|---|
committer | Nick Hudson <nick.hudson@isode.com> | 2015-04-20 09:54:22 (GMT) |
commit | de8538282dfbb73212fa241638147a64bbe9cee5 (patch) | |
tree | 607e31d3fd0c7e92ce2bc6c74ab9ec42f161b341 /src/com | |
parent | 4e52f24d7ca65b7274007ac3e5c0b6d9400d1bef (diff) | |
download | stroke-de8538282dfbb73212fa241638147a64bbe9cee5.zip stroke-de8538282dfbb73212fa241638147a64bbe9cee5.tar.bz2 |
Avoid potential double-adding of "lastConsumed" count to "bytesConsumed"
The code is currently doing
bytesConsumed += lastConsumed;
inside one of the clauses in a while loop, and then the same operation
again when the while loop exits. So there is a risk that the
"bytesConsumed" value will be too large.
In fact the only place the value of "bytesConsumed" is used is by some
code that checks whether it's greater than zero, so it would not be
problematic if the value were too large.
It seems worth fixing this in case future changes rely on the
"bytesConsumed" value being accurate.
Test-information:
inspection only
Change-Id: Ibd6fd01417afc4c4e030a5173bfba9a02980a757
signed-off-by:robert.williams@isode.com
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/isode/stroke/tls/java/JSSEContext.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/com/isode/stroke/tls/java/JSSEContext.java b/src/com/isode/stroke/tls/java/JSSEContext.java index 52edae1..da8316a 100644 --- a/src/com/isode/stroke/tls/java/JSSEContext.java +++ b/src/com/isode/stroke/tls/java/JSSEContext.java @@ -331,6 +331,9 @@ public class JSSEContext extends TLSContext { /* It consumed some bytes, but perhaps not everything */ unwrapDone = (lastConsumed == bytesToUnwrap); } + // At this stage "lastConsumed" has already been added to + // "bytesConsumed"; don't do it again after exiting the while loop + lastConsumed = 0; break; } } while (!unwrapDone); |