From 899b66ae131864964686f5572754aea03e10ffad Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 27 Sep 2023 20:49:16 +1000 Subject: [PATCH] BearSSL backend: Fix socket read/write errors not being initialised to 0 --- readme.md | 46 ++++++++++++-------------- src/SSL.c | 3 ++ third_party/bearssl/src/x509_minimal.c | 25 -------------- 3 files changed, 24 insertions(+), 50 deletions(-) diff --git a/readme.md b/readme.md index 6989f2db9..e3ac14bf7 100644 --- a/readme.md +++ b/readme.md @@ -65,28 +65,24 @@ ClassiCube runs on: * iOS - 10.3 or later * Most web browsers (even runs on IE11) -
- And also runs on: - -
+And also runs on: +* Raspberry Pi - needs libcurl and libopenal +* FreeBSD - needs libexecinfo, curl and openal-soft packages +* NetBSD - needs libexecinfo, curl and openal-soft packages +* OpenBSD - needs libexecinfo, curl and openal packages +* Solaris - needs curl and openal packages +* Haiku - needs openal package (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_haiku.yml)) +* BeOS - untested on actual hardware +* IRIX - needs curl and openal packages +* SerenityOS - needs SDL2 +* 3DS - unfinished, but usable (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_3ds.yml)) +* Wii - unfinished, but usable (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_wiigc.yml)) +* GameCube - unfinished, but usable (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_wiigc.yml)) +* Dreamcast - unfinished, but renders (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_dreamcast.yml)) +* PSP - unfinished, rendering issues (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_psp.yml)) +* 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)) +* 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)) +* PS3 - doesn't render properly yet # Compiling @@ -98,7 +94,7 @@ If you (not recommended) want to override the defaults (e.g. to compile OpenGL b ##### Using Visual Studio 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) 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 -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 @@ -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 -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 diff --git a/src/SSL.c b/src/SSL.c index 13b714496..1d52d1dfe 100644 --- a/src/SSL.c +++ b/src/SSL.c @@ -540,6 +540,9 @@ cc_result SSL_Init(cc_socket socket, const cc_string* host_, void** out_ctx) { br_sslio_init(&ctx->ioc, &ctx->sc.eng, sock_read, ctx, sock_write, ctx); + + ctx->readError = 0; + ctx->writeError = 0; return 0; } diff --git a/third_party/bearssl/src/x509_minimal.c b/third_party/bearssl/src/x509_minimal.c index 04f149b98..b3079deca 100644 --- a/third_party/bearssl/src/x509_minimal.c +++ b/third_party/bearssl/src/x509_minimal.c @@ -200,14 +200,6 @@ void br_x509_minimal_run(void *t0ctx); * then validation is reported as failed. */ -#if BR_USE_UNIX_TIME -#include -#endif - -#if BR_USE_WIN32_TIME -#include -#endif - /* * The T0 compiler will produce these prototypes declarations in the * header. @@ -1216,25 +1208,8 @@ br_x509_minimal_run(void *t0ctx) uint32_t vd = CTX->days; uint32_t vs = CTX->seconds; 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; T0_CO(); -#endif } if (vd < nbd || (vd == nbd && vs < nbs)) { r = -1;