forked from wolfSSL/wolfssl
sanity check in function GetInputData and when shrinking buffer
This commit is contained in:
@ -4814,7 +4814,7 @@ void ShrinkInputBuffer(WOLFSSL* ssl, int forcedFree)
|
|||||||
|
|
||||||
WOLFSSL_MSG("Shrinking input buffer\n");
|
WOLFSSL_MSG("Shrinking input buffer\n");
|
||||||
|
|
||||||
if (!forcedFree && usedLength)
|
if (!forcedFree && usedLength > 0)
|
||||||
XMEMCPY(ssl->buffers.inputBuffer.staticBuffer,
|
XMEMCPY(ssl->buffers.inputBuffer.staticBuffer,
|
||||||
ssl->buffers.inputBuffer.buffer + ssl->buffers.inputBuffer.idx,
|
ssl->buffers.inputBuffer.buffer + ssl->buffers.inputBuffer.idx,
|
||||||
usedLength);
|
usedLength);
|
||||||
@ -8902,14 +8902,16 @@ static int GetInputData(WOLFSSL *ssl, word32 size)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* check that no lengths or size values are negative */
|
||||||
|
if (usedLength < 0 || maxLength < 0 || inSz <= 0) {
|
||||||
|
return BUFFER_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (inSz > maxLength) {
|
if (inSz > maxLength) {
|
||||||
if (GrowInputBuffer(ssl, size + dtlsExtra, usedLength) < 0)
|
if (GrowInputBuffer(ssl, size + dtlsExtra, usedLength) < 0)
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inSz <= 0)
|
|
||||||
return BUFFER_ERROR;
|
|
||||||
|
|
||||||
/* Put buffer data at start if not there */
|
/* Put buffer data at start if not there */
|
||||||
if (usedLength > 0 && ssl->buffers.inputBuffer.idx != 0)
|
if (usedLength > 0 && ssl->buffers.inputBuffer.idx != 0)
|
||||||
XMEMMOVE(ssl->buffers.inputBuffer.buffer,
|
XMEMMOVE(ssl->buffers.inputBuffer.buffer,
|
||||||
|
Reference in New Issue
Block a user