src/wolfSSL/src/internal.c
int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength)
{
    byte* tmp;
    byte  hdrSz = DTLS_RECORD_HEADER_SZ;
    byte  align = ssl->options.dtls ? WOLFSSL_GENERAL_ALIGNMENT : 0;
    /* the encrypted data will be offset from the front of the buffer by
       the dtls record header, if the user wants encrypted alignment they need
       to define their alignment requirement. in tls we read record header
       to get size of record and put actual data back at front, so don't need */

    if (align) {
       while (align < hdrSz)
           align *= 2;
    }
    tmp = (byte*) XMALLOC(size + usedLength + align, ssl->heap,
                          DYNAMIC_TYPE_IN_BUFFER);
    WOLFSSL_MSG("growing input buffer\n");

    if (!tmp) return MEMORY_E;
    if (align)
        tmp += align - hdrSz;

    if (usedLength)
        XMEMCPY(tmp, ssl->buffers.inputBuffer.buffer +
                    ssl->buffers.inputBuffer.idx, usedLength);

    if (ssl->buffers.inputBuffer.dynamicFlag)
        XFREE(ssl->buffers.inputBuffer.buffer - ssl->buffers.inputBuffer.offset,
              ssl->heap,DYNAMIC_TYPE_IN_BUFFER);

    ssl->buffers.inputBuffer.dynamicFlag = 1;
    if (align)
        ssl->buffers.inputBuffer.offset = align - hdrSz;
    else
        ssl->buffers.inputBuffer.offset = 0;
    ssl->buffers.inputBuffer.buffer = tmp;
    ssl->buffers.inputBuffer.bufferSize = size + usedLength;
    ssl->buffers.inputBuffer.idx    = 0;
    ssl->buffers.inputBuffer.length = usedLength;

    return 0;
}
/* Grow the input buffer, should only be to read cert or big app data */
Grow the input buffer, should only be to read cert or big app data
Grow the input buffer should only be to read cert or big app data
int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength)
{
    byte* tmp;
    byte  hdrSz = DTLS_RECORD_HEADER_SZ;
    byte  align = ssl->options.dtls ? WOLFSSL_GENERAL_ALIGNMENT : 0;
    if (align) {
       while (align < hdrSz)
           align *= 2;
    }
    tmp = (byte*) XMALLOC(size + usedLength + align, ssl->heap,
                          DYNAMIC_TYPE_IN_BUFFER);
    WOLFSSL_MSG("growing input buffer\n");
    if (!tmp) return MEMORY_E;
    if (align)
        tmp += align - hdrSz;
    if (usedLength)
        XMEMCPY(tmp, ssl->buffers.inputBuffer.buffer +
                    ssl->buffers.inputBuffer.idx, usedLength);
    if (ssl->buffers.inputBuffer.dynamicFlag)
        XFREE(ssl->buffers.inputBuffer.buffer - ssl->buffers.inputBuffer.offset,
              ssl->heap,DYNAMIC_TYPE_IN_BUFFER);
    ssl->buffers.inputBuffer.dynamicFlag = 1;
    if (align)
        ssl->buffers.inputBuffer.offset = align - hdrSz;
    else
        ssl->buffers.inputBuffer.offset = 0;
    ssl->buffers.inputBuffer.buffer = tmp;
    ssl->buffers.inputBuffer.bufferSize = size + usedLength;
    ssl->buffers.inputBuffer.idx    = 0;
    ssl->buffers.inputBuffer.length = usedLength;
    return 0;
}
int GrowInputBuffer ( WOLFSSL * ssl , int size , int usedLength ) { byte * tmp ; byte hdrSz = DTLS_RECORD_HEADER_SZ ; byte align = ssl -> options . dtls ? WOLFSSL_GENERAL_ALIGNMENT : 0 ; if ( align ) { while ( align < hdrSz ) align *= 2 ; } tmp = ( byte * ) XMALLOC ( size + usedLength + align , ssl -> heap , DYNAMIC_TYPE_IN_BUFFER ) ; WOLFSSL_MSG ( " \n " ) ; if ( ! tmp ) return MEMORY_E ; if ( align ) tmp += align - hdrSz ; if ( usedLength ) XMEMCPY ( tmp , ssl -> buffers . inputBuffer . buffer + ssl -> buffers . inputBuffer . idx , usedLength ) ; if ( ssl -> buffers . inputBuffer . dynamicFlag ) XFREE ( ssl -> buffers . inputBuffer . buffer - ssl -> buffers . inputBuffer . offset , ssl -> heap , DYNAMIC_TYPE_IN_BUFFER ) ; ssl -> buffers . inputBuffer . dynamicFlag = 1 ; if ( align ) ssl -> buffers . inputBuffer . offset = align - hdrSz ; else ssl -> buffers . inputBuffer . offset = 0 ; ssl -> buffers . inputBuffer . buffer = tmp ; ssl -> buffers . inputBuffer . bufferSize = size + usedLength ; ssl -> buffers . inputBuffer . idx = 0 ; ssl -> buffers . inputBuffer . length = usedLength ; return 0 ; }
Grow the input buffer, should only be to read cert or big app data
Grow the input buffer should only be to read cert or big app data
/* the encrypted data will be offset from the front of the buffer by
       the dtls record header, if the user wants encrypted alignment they need
       to define their alignment requirement. in tls we read record header
       to get size of record and put actual data back at front, so don't need */