aboutsummaryrefslogtreecommitdiff
path: root/lib/std
AgeCommit message (Collapse)Author
2025-09-09std: add linger struct for SO.LINGERBrandon Black
2025-09-09std: add in_pktinfo and in6_pktinfo structs defsBrandon Black
in_pktinfo is only used on a few targets for the IP_PKTINFO sockopt, as many BSDs use an alternate mechanism (IP_RECVDSTADDR) that doesn't require a special struct. in6_pktinfo is more universal.
2025-09-09std.c: Add accept_filter_arg for some BSDsBrandon Black
This is the struct type used as set/getsockopt() option data with SO.ACCEPTFILTER, which is also only declared on this same limited set of BSD-ish targets. In theory this could be aliased over to std.posix as well, but I think for a corner case like this, it's not unreasonable for a user that is avoiding uneccessary std.c references to access it as "posix.system.accept_filter_arg" (which would still work fine if, in the future, FreeBSD escapes its libc dep and defines it in std.os.freebsd).
2025-09-09std: Add SCM constants for socket control messagesBrandon Black
2025-09-09Merge pull request #25191 from ziglang/fix-linker-undef-memoryAndrew Kelley
fix linker writing undefined memory to output file
2025-09-08Merge pull request #25190 from blblack/netcallsAndrew Kelley
Add missing posix wrappers for socketpair() and recvmsg()
2025-09-08std.Io.Writer.writeSliceEndian: add compile errorAndrew Kelley
check when an auto-layout struct is attempted to be memory reinterpreted and written out. it would be writing undefined memory
2025-09-08std.crypto.ed25519: support cofactorless verificationFrank Denis
Add verifyStrict() functions for cofactorless verification. Also: - Support messages < 64 characters in the test vectors - Allow mulDoubleBasePublic to return the identity as a regular value. There are valid use cases for this.
2025-09-08ECDSA signature der encoding should produce smallest number of octets (#25177)Igor Anić
I noticed this by stress testing my tls server implementation. From time to time curl (and other tools: ab, vegeta) will report invalid signature. I trace the problem to the way how std lib is encoding raw signature into der format. Using raw signature I got in some cases different encoding using std and openssl. Std is not producing minimal der when signature `r` or `s` integers has leading zero(es). Here is an example to illustrate difference. Notice leading 00 in `s` integer which is removed in openssl encoding but not in std encoding. ```Zig const std = @import("std"); test "ecdsa signature to der" { // raw signature r and s bytes const raw = hexToBytes( \\ 49 63 0c 94 95 2e ff 4b 02 bf 35 c4 97 9e a7 24 \\ 20 dc 94 de aa 1b 17 ff e1 49 25 3e 34 ef e8 d0 \\ c4 43 aa 7b a9 f3 9c b9 f8 72 7d d7 0c 9a 13 1e \\ \\ 00 56 85 43 d3 d4 05 62 a1 1d d8 a1 45 44 b5 dd \\ 62 9f d1 e0 ab f1 cd 4a 85 d0 1f 5d 11 d9 f8 89 \\ 89 d4 59 0c b0 6e ea 3c 19 6a f7 0b 1a 4a ce f1 ); // encoded by openssl const expected = hexToBytes( \\ 30 63 02 30 \\ 49 63 0c 94 95 2e ff 4b 02 bf 35 c4 97 9e a7 24 \\ 20 dc 94 de aa 1b 17 ff e1 49 25 3e 34 ef e8 d0 \\ c4 43 aa 7b a9 f3 9c b9 f8 72 7d d7 0c 9a 13 1e \\ \\ 02 2f \\ 56 85 43 d3 d4 05 62 a1 1d d8 a1 45 44 b5 dd \\ 62 9f d1 e0 ab f1 cd 4a 85 d0 1f 5d 11 d9 f8 89 \\ 89 d4 59 0c b0 6e ea 3c 19 6a f7 0b 1a 4a ce f1 ); // encoded by std const actual = hexToBytes( \\ 30 64 02 30 \\ 49 63 0c 94 95 2e ff 4b 02 bf 35 c4 97 9e a7 24 \\ 20 dc 94 de aa 1b 17 ff e1 49 25 3e 34 ef e8 d0 \\ c4 43 aa 7b a9 f3 9c b9 f8 72 7d d7 0c 9a 13 1e \\ \\ 02 30 \\ 00 56 85 43 d3 d4 05 62 a1 1d d8 a1 45 44 b5 dd \\ 62 9f d1 e0 ab f1 cd 4a 85 d0 1f 5d 11 d9 f8 89 \\ 89 d4 59 0c b0 6e ea 3c 19 6a f7 0b 1a 4a ce f1 ); _ = actual; const Ecdsa = std.crypto.sign.ecdsa.EcdsaP384Sha384; const sig = Ecdsa.Signature.fromBytes(raw); var buf: [Ecdsa.Signature.der_encoded_length_max]u8 = undefined; const encoded = sig.toDer(&buf); try std.testing.expectEqualSlices(u8, &expected, encoded); } pub fn hexToBytes(comptime hex: []const u8) [removeNonHex(hex).len / 2]u8 { @setEvalBranchQuota(1000 * 100); const hex2 = comptime removeNonHex(hex); comptime var res: [hex2.len / 2]u8 = undefined; _ = comptime std.fmt.hexToBytes(&res, hex2) catch unreachable; return res; } fn removeNonHex(comptime hex: []const u8) []const u8 { @setEvalBranchQuota(1000 * 100); var res: [hex.len]u8 = undefined; var i: usize = 0; for (hex) |c| { if (std.ascii.isHex(c)) { res[i] = c; i += 1; } } return res[0..i]; } ``` Trimming leading zeroes from signature integers fixes encoding.
2025-09-08recvmsg: posix wrapper, void on windowsBrandon Black
Also, added EPIPE to recvfrom() error set (it's a documented error for unix and tcp sockets, at least), which recvmsg() largely shares. Windows has an odd, callback-based form of recvmsg() that doesn't fit the normal interface here.
2025-09-08socketpair: posix wrapper, void on windowsBrandon Black
socketpair is something like a pipe2() for sockets, and generally only works for AF_UNIX sockets for most platforms. Winsock2 explicitly does not support this call, even though it does have AF_UNIX sockets.
2025-09-07std.mem.indexOfSentinel: eliminate unnecessary `@ptrCast`Andrew Kelley
it was always unnecessary but now it's illegal
2025-09-07std.debug.assertAligned: support const pointersAndrew Kelley
2025-09-06std.http.Client.Connection: make host() publicbaltevl
Closes #25153
2025-09-06Document std.mem.* functions (#25168)Frank Denis
* Document std.mem.* functions Functions in std.mem are essential for virtually all applications, yet many of them lacked documentation. Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-09-06Merge pull request #25163 from ziglang/packed-union-unusedAndrew Kelley
forbid unused bits in packed unions
2025-09-05remove ResponseStoragerpkak
unused since 5ce8e9325b7aa15cbcc77221fc7075b6c46619cc
2025-09-05std: update for new packed union rulesAndrew Kelley
2025-09-05Revert "Merge pull request #24905 from gooncreeper/file-reader-buffered"Andrew Kelley
This reverts commit ac42eaaadd0650ffc281f9a1ed1a642fde8984b7, reversing changes made to 9fa2394f8c00d060931d69fb6f342f7f2e3d826e. I would like a chance to review this, please. I already spotted some issues.
2025-09-05Merge pull request #24905 from gooncreeper/file-reader-bufferedIsaac Freund
Fix Io.Writer sendFile bugs with buffered reader contents
2025-09-05Merge pull request #25147 from lunagl/reenable-testsAlex Rønne Petersen
Reenable failing vector tests
2025-09-04std.fs.File.Writer: break up seekToAndrew Kelley
- introduce seekToUnbuffered which asserts no buffered data and does not have WriteFailed in the error set - remove WriteFailed from SeekError - make seekTo based on calling flush and then seekToUnbuffered - revert the change to reset seek_err since the error sets are compatible again
2025-09-04sendFileAll: use stream instead of sendFileReadingKendall Condon
This is a simpler implementation and allows file_reader to do more optimal streaming.
2025-09-04fix sendFile implementations bypassing interface bufferKendall Condon
Also removes `File.Reader.read` since it is otherwise unused and is a footgun.
2025-09-04File.Writer.sendFile: properly update reader posKendall Condon
seekBy affects the reader's physical position, not its logical position.
2025-09-04Reenable vector tests for armeb/thumbebLuna Schwalbe
https://github.com/ziglang/zig/issues/22060 has been fixed by upstream.
2025-09-04Reenable std.fmt.test.vector for riscv64Luna Schwalbe
The vector codegen issue as described in https://github.com/ziglang/zig/issues/4486 has been fixed upstream.
2025-09-04Merge pull request #25137 from alexrp/elf-gabi-4.3Alex Rønne Petersen
ELF updates for gABI 4.3
2025-09-03BitcodeReader: parse blockinfo inside blockLuna Schwalbe
Call start/endBlock before/after `parseBlockInfoBlock` in order to not use the current block context, which is wrong and leads to e.g. incorrect abbrevlen being used.
2025-09-03Add allocator that always failswhatisaphone
2025-09-03Fix cmsghdr struct for the *nixesBrandon Black
Previously we had a single definition of std.c.cmsghdr for all libc-linking platforms which aliased from the Solaris definition, a superfluous matching one in std.os.dragonfly, and no others. The existing definition from std.c didn't actually work for Linux, as Linux's "len" field is usize in the kernel's definition. Emscripten follows the Linux model of course (but uses the binary-compatible musl definition, which has an endian-sensitive padding scheme to make the len type "socklen_t" even though the kernel uses a usize, which is fair). This unifies and documents all the known *nix-ish cases (I'm not sure if wasi or windows really has cmsghdr support? Could be added later, void for now), such that c.cmsghdr and posix.system.cmsghdr should work correctly for all the known cases here, libc or otherwise.
2025-09-03fix: std.fs.File.Writer.seekTo does not flush (#25135)Josh GM Walker
* add failing test case * perform flush and allow error * dont over constrain flush error * reset seek error during conversion
2025-09-04Merge pull request #25125 from alexrp/loongarch-qemu-crashesAlex Rønne Petersen
`std.debug`: disable stack traces on loongarch
2025-09-04std.elf: change STV enum from u2 to u3Alex Rønne Petersen
In gABI 4.3, st_other was changed such that the lower 3 bits are reserved for the visibility, up from the previous 2 bits.
2025-09-04std.elf: add new EM values from gABI 4.3Alex Rønne Petersen
2025-09-04std.elf: document which EM values are not assigned in gABIAlex Rønne Petersen
2025-09-04std.elf: document which OSABI values are not assigned in gABIAlex Rønne Petersen
2025-09-03Return runtime err for EISCONN when connectingBrandon Black
Fixes #25063
2025-09-03std.c: add getresuid & getresgiddoclic
2025-09-03Merge pull request #25122 from linusg/fix-getrandombytesdevurandomAlex Rønne Petersen
std.posix: Fix getRandomBytesDevURandom()
2025-09-03std.debug: disable stack traces on loongarchAlex Rønne Petersen
Observed to ~randomly crash during FP-based unwinding. The path forward here will be DWARF-based unwinding.
2025-09-03lzma2: fix premature finishbinarycraft007
lzma2 Decoder already checks if decoding is finished or not inside the process function, `range_decoder`finish does not mean the decoder has finished, also need to check `ld.rep[0] == 0xFFFF_FFFF`, which was already done inside the proccess function. This fix delete the redundant `isFinish()` check for `range_decoder`.
2025-09-03std.c: Enable arc4random_buf for serenityLinus Groh
2025-09-03std.posix: Fix getRandomBytesDevURandom()Linus Groh
This is not exercised in CI because most platforms have a dedicated implementation in getrandom().
2025-09-02Merge pull request #25105 from binarycraft007/lzma2-fixAndrew Kelley
lzma2: fix array list looping logic in appendLz
2025-09-02std.compress.lzma2: optimize appendLzAndrew Kelley
make the hot loop be a for loop without any failures or allocation. change a O(N) addition into O(1)
2025-09-02zstd.Decompress: Assert buffer length requirements as early as possibleRyan Liptak
Without this assert, providing a buffer that's smaller than required results in more cryptic assertion failures later on.
2025-09-01lzma2: fix array list looping logic in appendLzbinarycraft007
2025-08-31Io.Writer.Allocating: test new *Aligned methodsTravis Staloch
* added initAligned() * added missing @alignCast in toArrayListAligned()
2025-08-31Merge pull request #25088 from ziglang/delete-deprecated-fmtAndrew Kelley
std.fmt: delete deprecated APIs