diff options
Diffstat (limited to 'src/bun.js/api')
-rw-r--r-- | src/bun.js/api/bun.zig | 8 | ||||
-rw-r--r-- | src/bun.js/api/bun/dns_resolver.zig | 25 | ||||
-rw-r--r-- | src/bun.js/api/bun/x509.zig | 6 | ||||
-rw-r--r-- | src/bun.js/api/ffi.zig | 4 |
4 files changed, 25 insertions, 18 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 2f42d821b..4c13214b3 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -1106,10 +1106,12 @@ pub const Crypto = struct { } pub fn reset(this: *EVP, engine: *BoringSSL.ENGINE) void { + BoringSSL.ERR_clear_error(); _ = BoringSSL.EVP_DigestInit_ex(&this.ctx, this.md, engine); } pub fn hash(this: *EVP, engine: *BoringSSL.ENGINE, input: []const u8, output: []u8) ?u32 { + BoringSSL.ERR_clear_error(); var outsize: c_uint = @min(@as(u16, @truncate(output.len)), this.size()); if (BoringSSL.EVP_Digest(input.ptr, input.len, output.ptr, &outsize, this.md, engine) != 1) { return null; @@ -1119,6 +1121,7 @@ pub const Crypto = struct { } pub fn final(this: *EVP, engine: *BoringSSL.ENGINE, output: []u8) []const u8 { + BoringSSL.ERR_clear_error(); var outsize: u32 = @min(@as(u16, @truncate(output.len)), this.size()); if (BoringSSL.EVP_DigestFinal_ex( &this.ctx, @@ -1134,6 +1137,7 @@ pub const Crypto = struct { } pub fn update(this: *EVP, input: []const u8) void { + BoringSSL.ERR_clear_error(); _ = BoringSSL.EVP_DigestUpdate(&this.ctx, input.ptr, input.len); } @@ -1142,6 +1146,7 @@ pub const Crypto = struct { } pub fn copy(this: *const EVP, engine: *BoringSSL.ENGINE) error{OutOfMemory}!EVP { + BoringSSL.ERR_clear_error(); var new = init(this.algorithm, this.md, engine); if (BoringSSL.EVP_MD_CTX_copy_ex(&new.ctx, &this.ctx) == 0) { return error.OutOfMemory; @@ -2012,7 +2017,6 @@ pub const Crypto = struct { pub const digest = JSC.wrapInstanceMethod(CryptoHasher, "digest_", false); pub const hash = JSC.wrapStaticMethod(CryptoHasher, "hash_", false); - pub fn getByteLength( this: *CryptoHasher, _: *JSC.JSGlobalObject, @@ -3609,7 +3613,7 @@ pub const Timer = struct { this.poll_ref.unref(vm); - this.timer.deinit(); + this.timer.deinit(false); // balance double unreffing in doUnref vm.event_loop_handle.?.num_polls += @as(i32, @intFromBool(this.did_unref_timer)); diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index eea516242..3c20f4df7 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -102,11 +102,12 @@ const LibInfo = struct { ) catch unreachable; const promise_value = request.head.promise.value(); + const hints = query.options.toLibC(); const errno = getaddrinfo_async_start_( &request.backend.libinfo.machport, name_z.ptr, null, - null, + if (hints != null) &hints.? else null, GetAddrInfoRequest.getAddrInfoAsyncCallback, request, ); @@ -860,7 +861,7 @@ pub const CAresNameInfo = struct { return; } var name_info = result.?; - const array = name_info.toJSReponse(this.globalThis.allocator(), this.globalThis); + const array = name_info.toJSResponse(this.globalThis.allocator(), this.globalThis); this.onComplete(array); return; } @@ -1250,7 +1251,7 @@ pub const CAresReverse = struct { return; } var node = result.?; - const array = node.toJSReponse(this.globalThis.allocator(), this.globalThis, ""); + const array = node.toJSResponse(this.globalThis.allocator(), this.globalThis, ""); this.onComplete(array); return; } @@ -1321,7 +1322,7 @@ pub fn CAresLookup(comptime cares_type: type, comptime type_name: []const u8) ty return; } var node = result.?; - const array = node.toJSReponse(this.globalThis.allocator(), this.globalThis, type_name); + const array = node.toJSResponse(this.globalThis.allocator(), this.globalThis, type_name); this.onComplete(array); return; } @@ -1536,7 +1537,7 @@ pub const DNSResolver = struct { var pending: ?*CAresLookup(cares_type, lookup_name) = key.lookup.head.next; var prev_global = key.lookup.head.globalThis; - var array = addr.toJSReponse(this.vm.allocator, prev_global, lookup_name); + var array = addr.toJSResponse(this.vm.allocator, prev_global, lookup_name); defer addr.deinit(); array.ensureStillAlive(); key.lookup.head.onComplete(array); @@ -1547,7 +1548,7 @@ pub const DNSResolver = struct { while (pending) |value| { var new_global = value.globalThis; if (prev_global != new_global) { - array = addr.toJSReponse(this.vm.allocator, new_global, lookup_name); + array = addr.toJSResponse(this.vm.allocator, new_global, lookup_name); prev_global = new_global; } pending = value.next; @@ -1666,7 +1667,7 @@ pub const DNSResolver = struct { // The callback need not and should not attempt to free the memory // pointed to by hostent; the ares library will free it when the // callback returns. - var array = addr.toJSReponse(this.vm.allocator, prev_global, ""); + var array = addr.toJSResponse(this.vm.allocator, prev_global, ""); array.ensureStillAlive(); key.lookup.head.onComplete(array); bun.default_allocator.destroy(key.lookup); @@ -1676,7 +1677,7 @@ pub const DNSResolver = struct { while (pending) |value| { var new_global = value.globalThis; if (prev_global != new_global) { - array = addr.toJSReponse(this.vm.allocator, new_global, ""); + array = addr.toJSResponse(this.vm.allocator, new_global, ""); prev_global = new_global; } pending = value.next; @@ -1707,7 +1708,7 @@ pub const DNSResolver = struct { var pending: ?*CAresNameInfo = key.lookup.head.next; var prev_global = key.lookup.head.globalThis; - var array = name_info.toJSReponse(this.vm.allocator, prev_global); + var array = name_info.toJSResponse(this.vm.allocator, prev_global); array.ensureStillAlive(); key.lookup.head.onComplete(array); bun.default_allocator.destroy(key.lookup); @@ -1717,7 +1718,7 @@ pub const DNSResolver = struct { while (pending) |value| { var new_global = value.globalThis; if (prev_global != new_global) { - array = name_info.toJSReponse(this.vm.allocator, new_global); + array = name_info.toJSResponse(this.vm.allocator, new_global); prev_global = new_global; } pending = value.next; @@ -2475,7 +2476,7 @@ pub const DNSResolver = struct { return dns_lookup.promise.value(); } - // var hints_buf = &[_]c_ares.AddrInfo_hints{query.toCAres()}; + var hints_buf = &[_]c_ares.AddrInfo_hints{query.toCAres()}; var request = GetAddrInfoRequest.init( cache, .{ @@ -2491,7 +2492,7 @@ pub const DNSResolver = struct { channel.getAddrInfo( query.name, query.port, - &.{}, + hints_buf, GetAddrInfoRequest, request, GetAddrInfoRequest.onCaresComplete, diff --git a/src/bun.js/api/bun/x509.zig b/src/bun.js/api/bun/x509.zig index 9c902b39c..a94d47c45 100644 --- a/src/bun.js/api/bun/x509.zig +++ b/src/bun.js/api/bun/x509.zig @@ -273,7 +273,8 @@ fn x509PrintGeneralName(out: *BoringSSL.BIO, name: *BoringSSL.GENERAL_NAME) bool // instead always print its numeric representation. var oline: [256]u8 = undefined; _ = BoringSSL.OBJ_obj2txt(&oline, @sizeOf(@TypeOf(oline)), name.d.rid, 1); - _ = BoringSSL.BIO_printf(out, "Registered ID:%s", &oline); + // Workaround for https://github.com/ziglang/zig/issues/16197 + _ = BoringSSL.BIO_printf(out, "Registered ID:%s", @as([*]const u8, &oline)); } else if (name.name_type == .GEN_X400) { _ = BoringSSL.BIO_printf(out, "X400Name:<unsupported>"); } else if (name.name_type == .GEN_EDIPARTY) { @@ -301,7 +302,8 @@ fn x509InfoAccessPrint(out: *BoringSSL.BIO, ext: *BoringSSL.X509_EXTENSION) bool } var tmp: [80]u8 = undefined; _ = BoringSSL.i2t_ASN1_OBJECT(&tmp, @sizeOf(@TypeOf(tmp)), desc.method); - _ = BoringSSL.BIO_printf(out, "%s - ", &tmp); + // Workaround for https://github.com/ziglang/zig/issues/16197 + _ = BoringSSL.BIO_printf(out, "%s - ", @as([*]const u8, &tmp)); if (!x509PrintGeneralName(out, desc.location)) { return false; diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index 234b58888..a7a03e784 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -317,9 +317,9 @@ pub const FFI = struct { }; }; }; - + var size = symbols.values().len; - if(size >= 63) { + if (size >= 63) { size = 0; } var obj = JSC.JSValue.createEmptyObject(global, size); |