File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
main/java/net/schmizz/sshj/common
test/java/net/schmizz/sshj/common Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -372,6 +372,7 @@ public T putUInt64(BigInteger uint64) {
372
372
373
373
@ SuppressWarnings ("unchecked" )
374
374
private T putUInt64Unchecked (long uint64 ) {
375
+ ensureCapacity (8 );
375
376
data [wpos ++] = (byte ) (uint64 >> 56 );
376
377
data [wpos ++] = (byte ) (uint64 >> 48 );
377
378
data [wpos ++] = (byte ) (uint64 >> 40 );
Original file line number Diff line number Diff line change @@ -146,4 +146,28 @@ public void shouldHaveSameUInt64EncodingForBigIntegerAndLong() {
146
146
assertArrayEquals ("Value: " + value , bytesLong , bytesBigInt );
147
147
}
148
148
}
149
+
150
+
151
+ @ Test
152
+ public void shouldExpandCapacityOfUInt32 (){
153
+ PlainBuffer buf = new PlainBuffer ();
154
+ for (int i =0 ;i <Buffer .DEFAULT_SIZE +1 ;i +=4 ) {
155
+ buf .putUInt32 (1l );
156
+ }
157
+ /* Buffer should have been expanded at this point*/
158
+ assertEquals (Buffer .DEFAULT_SIZE *2 ,buf .data .length );
159
+ }
160
+
161
+ @ Test
162
+ public void shouldExpandCapacityOfUInt64 (){
163
+ BigInteger bigUint64 = BigInteger .valueOf (Long .MAX_VALUE );
164
+ PlainBuffer buf = new PlainBuffer ();
165
+ assertEquals (Buffer .DEFAULT_SIZE ,buf .data .length );
166
+ for (int i =0 ;i <Buffer .DEFAULT_SIZE +1 ;i +=8 ) {
167
+ buf .putUInt64 (bigUint64 .longValue ());
168
+ }
169
+ /* Buffer should have been expanded at this point*/
170
+ assertEquals (Buffer .DEFAULT_SIZE *2 ,buf .data .length );
171
+ }
172
+
149
173
}
You can’t perform that action at this time.
0 commit comments