Topic: wolfSSL_read function returns -132

Hi,

I am using wolfSSL library to send the data with SSL security. I can get the actual data. But when the read operation occurs for the second time I am getting -132 (Output buffer too small or input too large) error value from wolfssl_read data. Could you please tell me the reason for getting this error?

Here are the other details,
1. Board : ZCU102.
2. OS : FreeRTOS.
3. TCP/IP stack : LwIP.
4. WolfSSL version : 4.7.0.

Best regards,
Iyyappan.

Share

Re: wolfSSL_read function returns -132

Hi Iyyappan,

Can you share a snippet of your code calling wolfSSL_read()? Also can you call `err = wolfSSL_get_error(ssl, 0);` and see if any other error code is returned? Also can you enable logging using DEBUG_WOLFSSL and calling wolfSSL_Debugging_ON()?

I suspect either an issue with heap memory exhausted or the supplied argument to wolfSSL_read invalid.

Thanks,
David Garske, wolfSSL

Share

Re: wolfSSL_read function returns -132

Hi David,

Thank you for your reply.

Here is the snippet of the code calling wolfssl_read.

        //Receive data from socket.
        char buf[RECV_BUFFER_SIZE_BYTES] = {0}; //16384 bytes

        while (true)
        {
            memset(buf, 0, RECV_BUFFER_SIZE_BYTES);

            // Wait for client to send data
            ssize_t bytesReceived = wolfSSL_read(reinterpret_cast<WOLFSSL*>(pReqHandler->getContext()), buf, sizeof(buf));

            if (bytesReceived < 0)
            {
                ERROR1("\r\nwolfSSL_read", "requestHandlerThreadProc()", getWolfSSLErrString(pReqHandler->getContext()));
                break;
            }
            if (bytesReceived == SSL_ERROR_WANT_READ || bytesReceived == SSL_ERROR_WANT_WRITE)
            {
                continue;
            }
            if (bytesReceived == 0)
            {
                break;
            }
        }
        vTaskDelete(NULL);

The above function runs in thread. For each socket separate thread will be created. "sys_thread_new" function (LwIP library  function) used to create threads.

Here is the log info of wolfSSL after adding DEBUG_WOLFSSL.

wolfSSL Entering wolfSSL_read()
wolfSSL Entering wolfSSL_read_internal()
wolfSSL Entering ReceiveData()
growing input buffer

received record layer msg
got ALERT!
wolfSSL error occurred, error = -132
wolfSSL Leaving wolfSSL_read_internal(), return -132

Regards,
Iyyappan.

Share

Re: wolfSSL_read function returns -132

Hi Iyyappan,

Can you provide me your build settings? Are you using custom IO callbacks for the LWIP layer or the LWIP socket layer and wolfio.c default implementation? Its possible the callback is not returning the right values.

Since you are using multi-threading I assume you have `FREERTOS` defined for mutex protection. Even so you may not use the same WOLFSSL object from more than one thread. There is a feature you can use to duplicate the WOLFSSL object so you have one for reading and another for writing. If interested that is `HAVE_WRITE_DUP` and `wolfSSL_write_dup`.

Thanks,
David Garske, wolfSSL

Share