Commit c0c94bd8 authored by ROOL's avatar ROOL 🤖
Browse files

Fix for using uninitialised value in decision

Detail:
  It isn't possible to read FIONBIO using socketioctl, the Internet module returns -1 before writing the output variable, leaving it uninitialised.
  Track the FIONBIO state using an extra member in the mbedtls_net_context structure, so it can be read when needed.
Admin:
  Submission for TCP/IP bounty.

Version 2.12. Tagged as 'mbedTLS-2_12'
parent b11607d3
/* (2.11)
/* (2.12)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.11
#define Module_MajorVersion_CMHG 2.12
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Dec 2018
#define Module_Date_CMHG 27 Jan 2019
#define Module_MajorVersion "2.11"
#define Module_Version 211
#define Module_MajorVersion "2.12"
#define Module_Version 212
#define Module_MinorVersion ""
#define Module_Date "28 Dec 2018"
#define Module_Date "27 Jan 2019"
#define Module_ApplicationDate "28-Dec-18"
#define Module_ApplicationDate "27-Jan-19"
#define Module_ComponentName "mbedTLS"
#define Module_ComponentPath "apache/RiscOS/Sources/Lib/mbedTLS"
#define Module_FullVersion "2.11"
#define Module_HelpVersion "2.11 (28 Dec 2018)"
#define Module_LibraryVersionInfo "2:11"
#define Module_FullVersion "2.12"
#define Module_HelpVersion "2.12 (27 Jan 2019)"
#define Module_LibraryVersionInfo "2:12"
......@@ -291,15 +291,10 @@ int mbedtls_net_bind(mbedtls_net_context *ctx,
*/
static int net_would_block(const mbedtls_net_context *ctx)
{
int nbio, olderrno;
/*
* Never return 'WOULD BLOCK' on a non-blocking socket
*/
olderrno = errno;
socketioctl(ctx->fd, _IOR('f', 126, int) /* Read FIONBIO */, &nbio);
errno = olderrno;
if (!nbio)
if (!ctx->nbio)
{
return 0;
}
......@@ -425,6 +420,7 @@ int mbedtls_net_set_block(mbedtls_net_context *ctx)
{
int on = 0;
ctx->nbio = on;
return socketioctl(ctx->fd, FIONBIO, &on);
}
......@@ -432,6 +428,7 @@ int mbedtls_net_set_nonblock(mbedtls_net_context *ctx)
{
int on = 1;
ctx->nbio = on;
return socketioctl(ctx->fd, FIONBIO, &on);
}
......
......@@ -87,6 +87,9 @@ extern "C" {
typedef struct mbedtls_net_context
{
int fd; /**< The underlying file descriptor */
#ifdef __riscos
int nbio; /**< Flag to remember write only FIONBIO state */
#endif
}
mbedtls_net_context;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment