BearSSL backend: Fix socket read/write errors not being initialised to 0

This commit is contained in:
UnknownShadow200 2023-09-27 20:49:16 +10:00
parent 388b9daac4
commit 899b66ae13
3 changed files with 24 additions and 50 deletions

View File

@ -65,28 +65,24 @@ ClassiCube runs on:
* iOS - 10.3 or later * iOS - 10.3 or later
* Most web browsers (even runs on IE11) * Most web browsers (even runs on IE11)
<details> And also runs on:
<summary>And also runs on:</summary> * Raspberry Pi - needs <code>libcurl</code> and <code>libopenal</code>
<ul> * FreeBSD - needs <code>libexecinfo</code>, <code>curl</code> and <code>openal-soft</code> packages
<li> Raspberry Pi - needs <code>libcurl</code> and <code>libopenal</code> </li> * NetBSD - needs <code>libexecinfo</code>, <code>curl</code> and <code>openal-soft</code> packages
<li> FreeBSD - needs <code>libexecinfo</code>, <code>curl</code> and <code>openal-soft</code> packages </li> * OpenBSD - needs <code>libexecinfo</code>, <code>curl</code> and <code>openal</code> packages
<li> NetBSD - needs <code>libexecinfo</code>, <code>curl</code> and <code>openal-soft</code> packages </li> * Solaris - needs <code>curl</code> and <code>openal</code> packages
<li> OpenBSD - needs <code>libexecinfo</code>, <code>curl</code> and <code>openal</code> packages </li> * Haiku - needs <code>openal</code> package (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_haiku.yml))
<li> Solaris - needs <code>curl</code> and <code>openal</code> packages </li> * BeOS - untested on actual hardware
<li> Haiku - needs <code>openal</code> package </li> * IRIX - needs <code>curl</code> and <code>openal</code> packages
<li> BeOS - untested on actual hardware </li> * SerenityOS - needs <code>SDL2</code>
<li> IRIX - needs <code>curl</code> and <code>openal</code> packages </li> * 3DS - unfinished, but usable (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_3ds.yml))
<li> SerenityOS - needs <code>SDL2</code> </li> * Wii - unfinished, but usable (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_wiigc.yml))
<li> 3DS - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_3ds.yml">unfinished, but usable</a> </li> * GameCube - unfinished, but usable (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_wiigc.yml))
<li> Wii - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_wiigc.yml">unfinished, but usable</a> </li> * Dreamcast - unfinished, but renders (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_dreamcast.yml))
<li> GameCube - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_wiigc.yml">unfinished, but usable</a> </li> * PSP - unfinished, rendering issues (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_psp.yml))
<li> Dreamcast - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_dreamcast.yml">unfinished, but renders</a> </li> * PS Vita - unfinished, rendering issues (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_vita.yml))
<li> PSP - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_psp.yml">unfinished, rendering issues</a> </li> * Xbox - unfinished, major rendering issues (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_xbox.yml))
<li> PS Vita - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_vita.yml">unfinished, rendering issues</a> </li> * PS3 - doesn't render properly yet
<li> Xbox -<a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_xbox"> unfinished, major rendering issues</a> </li>
<li> PS3 - doesn't render properly yet </li>
</ul>
</details>
# Compiling # Compiling
@ -98,7 +94,7 @@ If you (not recommended) want to override the defaults (e.g. to compile OpenGL b
##### Using Visual Studio ##### Using Visual Studio
Open ClassiCube.sln *(File -> Open -> Project/Solution)* and compile it *(Build -> Build Solution)*. Open ClassiCube.sln *(File -> Open -> Project/Solution)* and compile it *(Build -> Build Solution)*.
If you get a ```The Windows SDK version 5.1 was not found``` compilation error, [see here for how to fix](doc/compile-fixes.md#visual-studio-unsupported-platform-toolset) If you get a `The Windows SDK version 5.1 was not found` compilation error, [see here for how to fix](doc/compile-fixes.md#visual-studio-unsupported-platform-toolset)
##### Using Visual Studio (command line) ##### Using Visual Studio (command line)
1. Use 'Developer Tools for Visual Studio' from Start Menu 1. Use 'Developer Tools for Visual Studio' from Start Menu
@ -161,7 +157,7 @@ Although the regular linux compiliation flags will work fine, to take full advan
## Compiling - for Android ## Compiling - for Android
NOTE: If you are distributing a modified version, please change the package ID from `com.classicube.android.client` to something else - otherwise Android users won't be able to have both ClassiCube and your modified version installed at the same time on their Android device NOTE: If you are distributing a modified version, **please change the package ID from `com.classicube.android.client` to something else** - otherwise Android users won't be able to have both ClassiCube and your modified version installed at the same time on their Android device
##### Using Android Studio GUI ##### Using Android Studio GUI
@ -175,7 +171,7 @@ Run `gradlew` in android folder (TODO explain more detailed)
iOS version will have issues as it's incomplete and only tested in iOS Simulator iOS version will have issues as it's incomplete and only tested in iOS Simulator
NOTE: If you are distributing a modified version, please change the bundle ID from `com.classicube.ios.client` to something else - otherwise iOS users won't be able to have both ClassiCube and your modified version installed at the same time on their iOS device NOTE: If you are distributing a modified version, **please change the bundle ID from `com.classicube.ios.client` to something else** - otherwise iOS users won't be able to have both ClassiCube and your modified version installed at the same time on their iOS device
##### Using Xcode GUI ##### Using Xcode GUI

View File

@ -541,6 +541,9 @@ cc_result SSL_Init(cc_socket socket, const cc_string* host_, void** out_ctx) {
sock_read, ctx, sock_read, ctx,
sock_write, ctx); sock_write, ctx);
ctx->readError = 0;
ctx->writeError = 0;
return 0; return 0;
} }

View File

@ -200,14 +200,6 @@ void br_x509_minimal_run(void *t0ctx);
* then validation is reported as failed. * then validation is reported as failed.
*/ */
#if BR_USE_UNIX_TIME
#include <time.h>
#endif
#if BR_USE_WIN32_TIME
#include <windows.h>
#endif
/* /*
* The T0 compiler will produce these prototypes declarations in the * The T0 compiler will produce these prototypes declarations in the
* header. * header.
@ -1216,25 +1208,8 @@ br_x509_minimal_run(void *t0ctx)
uint32_t vd = CTX->days; uint32_t vd = CTX->days;
uint32_t vs = CTX->seconds; uint32_t vs = CTX->seconds;
if (vd == 0 && vs == 0) { if (vd == 0 && vs == 0) {
#if BR_USE_UNIX_TIME
time_t x = time(NULL);
vd = (uint32_t)(x / 86400) + 719528;
vs = (uint32_t)(x % 86400);
#elif BR_USE_WIN32_TIME
FILETIME ft;
uint64_t x;
GetSystemTimeAsFileTime(&ft);
x = ((uint64_t)ft.dwHighDateTime << 32)
+ (uint64_t)ft.dwLowDateTime;
x = (x / 10000000);
vd = (uint32_t)(x / 86400) + 584754;
vs = (uint32_t)(x % 86400);
#else
CTX->err = BR_ERR_X509_TIME_UNKNOWN; CTX->err = BR_ERR_X509_TIME_UNKNOWN;
T0_CO(); T0_CO();
#endif
} }
if (vd < nbd || (vd == nbd && vs < nbs)) { if (vd < nbd || (vd == nbd && vs < nbs)) {
r = -1; r = -1;