From d19c18580b457173d059279faaab5a6f083e61e3 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Tue, 19 Nov 2024 00:23:27 -0300 Subject: [PATCH] fix(tls) fix type matching (#15224) --- packages/bun-usockets/src/libusockets.h | 5 +++-- src/deps/boringssl.translated.zig | 2 +- src/deps/uws.zig | 7 ++++--- src/http.zig | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/bun-usockets/src/libusockets.h b/packages/bun-usockets/src/libusockets.h index d2719af2c90e7c..94dd58e22b52ad 100644 --- a/packages/bun-usockets/src/libusockets.h +++ b/packages/bun-usockets/src/libusockets.h @@ -84,7 +84,7 @@ #endif #include "stddef.h" - +#include #ifdef __cplusplus extern "C" { #endif @@ -190,7 +190,8 @@ struct us_socket_context_options_t { }; struct us_bun_verify_error_t { - long error; + // this is a int64_t because can store a result of BoringSSL.SSL_get_verify_result that uses a long + int64_t error; const char* code; const char* reason; }; diff --git a/src/deps/boringssl.translated.zig b/src/deps/boringssl.translated.zig index ee25a0948daf9d..b636e042c5c95e 100644 --- a/src/deps/boringssl.translated.zig +++ b/src/deps/boringssl.translated.zig @@ -18886,7 +18886,7 @@ pub const CertError = error{ UNKKNOW_CERTIFICATE_VERIFICATION_ERROR, }; -pub fn getCertErrorFromNo(error_no: i32) CertError { +pub fn getCertErrorFromNo(error_no: i64) CertError { return switch (error_no) { X509_V_OK => error.OK, X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT => error.UNABLE_TO_GET_ISSUER_CERT, diff --git a/src/deps/uws.zig b/src/deps/uws.zig index 5e3256130fa956..b50e1e76dbcbf3 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -95,7 +95,7 @@ pub const InternalLoopData = extern struct { pub const UpgradedDuplex = struct { pub const CertError = struct { - error_no: i32 = 0, + error_no: i64 = 0, code: [:0]const u8 = "", reason: [:0]const u8 = "", @@ -1700,7 +1700,7 @@ pub fn NewSocketHandler(comptime is_ssl: bool) type { return this.getError() != 0; } - pub fn getError(this: ThisSocket) i32 { + pub fn getError(this: ThisSocket) i64 { switch (this.socket) { .connected => |socket| { return us_socket_get_error( @@ -2643,7 +2643,8 @@ pub const create_bun_socket_error_t = enum(i32) { }; pub const us_bun_verify_error_t = extern struct { - error_no: i32 = 0, + // this is a i64 because can store a result of BoringSSL.SSL_get_verify_result that uses a long + error_no: i64 = 0, code: [*c]const u8 = null, reason: [*c]const u8 = null, }; diff --git a/src/http.zig b/src/http.zig index 240c5c790ab806..9f915a54d94df2 100644 --- a/src/http.zig +++ b/src/http.zig @@ -320,7 +320,7 @@ const ProxyTunnel = struct { this.state.request_stage = .proxy_headers; this.state.request_sent_len = 0; const handshake_error = HTTPCertError{ - .error_no = ssl_error.error_no, + .error_no = @intCast(ssl_error.error_no), .code = if (ssl_error.code == null) "" else ssl_error.code[0..bun.len(ssl_error.code) :0], .reason = if (ssl_error.code == null) "" else ssl_error.reason[0..bun.len(ssl_error.reason) :0], }; @@ -511,7 +511,7 @@ const ProxyTunnel = struct { }; pub const HTTPCertError = struct { - error_no: i32 = 0, + error_no: i64 = 0, code: [:0]const u8 = "", reason: [:0]const u8 = "", };