libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.39k stars 1.84k forks source link

Follow mbedtls API: check all return values in net_socket_ssl.c #7747

Open ofry opened 5 years ago

ofry commented 5 years ago

First and foremost consider this:

Description

Follow mbedtls API: check return values after any mbedtls-related function call in file libretro-common/net/net_socket_ssl.c

MbedTLS API is there: https://tls.mbed.org/api/index.html

Examples:

https://tls.mbed.org/api/net__sockets_8h.html#aeea4e6fd5ad3167bf8563e61f6f75963 https://tls.mbed.org/api/ssl_8h.html#a5bbda87d484de82df730758b475f32e5

Related to #7451

Steps to reproduce the bug

  1. [First step]
  2. [Second step]
  3. [and so on...]

Bisect Results

[Try to bisect and tell us when this started happening]

Version/Commit

You can find this information under Information/System Information

Environment information

orbea commented 5 years ago

Is this not a duplicate of the existing issue?

ofry commented 5 years ago

I'm not sure will rewrite this code solve #7451 or not. However, not checking these return values is bug anyway.

orbea commented 5 years ago

Now that the other issue is solved, what specific cases is the API not being followed?

ofry commented 5 years ago

mbedtls_ssl_write()

Warning This function will do partial writes in some cases. If the return value is non-negative but less than length, the function must be called again with updated arguments: buf + ret, len - ret (if ret is the return value) until it returns a value equal to the last 'len' argument.

mbedtls_net_set_block(), mbedtls_net_set_nonblock()

Returns 0 if successful, or a non-zero error code

LibretroAdmin commented 2 years ago

@Cthulhu-throwaway Is it prudent to do this?