11348 Commits

Author SHA1 Message Date
Alex Rønne Petersen
90c1123d1c
std.mem: work around LoongArch inline asm bug in doNotOptimizeAway()
https://github.com/llvm/llvm-project/issues/159200
2025-09-19 12:13:21 +02:00
Frank Denis
91eab35e08
std.sort.pdq: fix out-of-bounds access in partialInsertionSort (#25253)
* std.sort.pdq: fix out-of-bounds access in partialInsertionSort

When sorting a sub-range that doesn't start at index 0, the
partialInsertionSort function could access indices below the range
start. The loop condition `while (j >= 1)` didn't respect the
arbitrary range boundaries [a, b).

This changes the condition to `while (j > a)` to ensure indices
never go below the range start, fixing the issue where pdqContext
would access out-of-bounds indices.

Fixes #25250
2025-09-18 12:47:18 +02:00
Ryan Liptak
72017d4bd5
mem.replace: Document that input/output cannot overlap 2025-09-18 12:47:18 +02:00
mlugg
83a3365bfd
std.math.big.int: normalize zero result for small multiplications
Resolves: #25221
2025-09-16 13:50:33 +02:00
George Huebner
05b7ca6356
bpf: use bitCast instead of intCast in ld_imm_impl
Any 32 bit immediate is allowed in a BPF instruction, including those
greater than the largest positive i32 value.
2025-09-16 13:50:08 +02:00
Andrew Kelley
f06c3d8be7
std.debug.assertAligned: support const pointers 2025-09-12 02:33:35 +02:00
Luna Schwalbe
30ec163d14
BitcodeReader: parse blockinfo inside block
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-07 00:34:14 +02:00
Tadej Gašparovič
dcddbcaa60
Fix regression: std.http.Client basic authorization sending user:user instead of user:password when passed in URI 2025-09-02 22:34:51 +02:00
Brandon Mercer
b72a02c592
Populate MSG struct for OpenBSD (#25076)
* update the MSG struct with the correct values for openbsd

* add comment with link to sys/sys/socket.h

---------

Co-authored-by: Brandon Mercer <bmercer@eutonian.com>
2025-09-02 22:34:35 +02:00
Alex Rønne Petersen
d8d497ffe4
std.Thread: make unreachable errors in sleep() clearer 2025-09-02 22:33:35 +02:00
Alex Rønne Petersen
00fb5e34df
std.Target: fix alignment for int/long types on m68k 2025-09-02 22:32:17 +02:00
Ryan Liptak
cbc3c0dc59
process.totalSystemMemory: Avoid overflow on Linux when totalram is a 32-bit usize
Fixes #25038
2025-08-29 00:13:01 +02:00
tokyo4j
cb9821a827
std.os.uefi: fix type error at MemoryType.format() 2025-08-29 00:12:44 +02:00
Alex Rønne Petersen
1231c8fbbd
std.os.linux: powerpc syscalls clobber ctr and xer
https://git.musl-libc.org/cgit/musl/commit/?id=f6944eb3c4ce1c97dc39dc36d32390dc9f70b67b
2025-08-29 00:12:39 +02:00
Brandon Black
9dc3fce4c4
std.c: add correct SOMAXCONN for BSDs
Note the previous "28" here for openbsd was some kind of copy
error long ago.  That's the value of KERN.SOMAXCONN, which is an
entirely different thing.
2025-08-27 20:53:49 +02:00
Frank Denis
9c3e09cbee
Fix TLS 1.2 client key exchange to use negotiated named group (#25007)
The TLS 1.2 implementation was incorrectly hardcoded to always send the
secp256r1 public key in the client key exchange message, regardless of
which elliptic curve the server actually negotiated.

This caused TLS handshake failures with servers that preferred other curves
like X25519.

This fix:

- Tracks the negotiated named group from the server key exchange message
- Dynamically selects the correct public key (X25519, secp256r1, or
  secp384r1) based on what the server negotiated
- Properly constructs the client key exchange message with the
  appropriate key size for each curve type

Fixes TLS 1.2 connections to servers like ziglang.freetls.fastly.net
that prefer X25519 over secp256r1.
2025-08-27 20:53:42 +02:00
mlugg
a4cb636658
std.Build.WebServer: fix race
Just a typo: I wasn't actually using the duped message, so the message I
sent could be freed in this interval.
2025-08-26 21:17:38 +02:00
AdamGoertz
e323dbfd15
std.Build.Step.TranslateC: forward --cache-dir and --global-cache-dir flags 2025-08-26 17:56:23 +02:00
Ian Johnson
628357eeb6
std.Build.Step.Compile: fix race condition in args file creation
Fixes #23993

Previously, if multiple build processes tried to create the same args file, there was a race condition with the use of the non-atomic `writeFile` function which could cause a spawned compiler to read an empty or incomplete args file. This commit avoids the race condition by first writing to a temporary file with a random path and renaming it to the desired path.
2025-08-26 17:56:01 +02:00
Qun He
caa89c7601
os.linux: faccessat wrapper prefer to faccessat syscall when flags is zero.
This make `fs.Dir.access` has compatibility like the zig version before.

With this change the `zig build --search-prefix` command would work again like
the zig 0.14 version when used on Ubuntu22.04, kernel version 5.4.
2025-08-26 00:11:43 +02:00
Sardorbek Imomaliev
6f07cc95d0
add macOS handling for totalSystemMemory (#24903)
* add macos handling for totalSystemMemory

* fix return type cast for .freebsd in totalSystemMemory

* add handling for the whole Darwin family in totalSystemMemory
2025-08-26 00:11:34 +02:00
Becker A.
9ef2208e4b
Update powi.zig to fix docstring formatting
Without this change, the docs are formatted s.t. the text "Edge case rules ordered by precedence:" is appended onto the prior line of text "Underflow: Absolute value of result smaller than 1", instead of getting its own line.
2025-08-25 18:51:41 +02:00
87
d4e5d1e15c
lib: Reword documentation for realloc to clarify size
"byte size" is confusing. Clarify we mean number of items.
2025-08-25 18:51:26 +02:00
Alex Rønne Petersen
f96321be90
std.zig.system: fix check for sparc "v8+" in getExternalExecutor()
Targeting v9 on sparc32 doesn't by itself imply "v8+" mode (64-bit instructions
in 32-bit code).
2025-08-25 18:50:48 +02:00
Erik Schlyter
a51e88c3b1
Fix #24999: copy left-overs before we XOR into c. (#25001)
It is important we copy the left-overs in the message *before* we XOR
it into the ciphertext, because if we're encrypting in-place (i.e., m ==
c), we will manipulate the message that will be used for tag generation.
This will generate faulty tags when message length doesn't conform with
16 byte blocks.
2025-08-25 18:50:36 +02:00
Alex Rønne Petersen
98585af51d
std.fs.Dir: fix updateFile() to flush the file before updating its times
AtomicFile.finish() calls flush() which renders any previous updateTimes() calls
useless. Regression introduced in f2a3ac7c0534a74ee544fdf6ef9d2176a8d62389.

Closes #24927.
2025-08-24 02:30:31 +02:00
John Benediktsson
38ef3f8997
Merge pull request #24926 from mrjbq7/http-fetch
http.Client: don't forget to flush
2025-08-22 23:23:18 +02:00
Raiden1411
c8ec7c1294
std: remove lossy int to float coercion on json parse 2025-08-22 04:19:22 +02:00
Lwazi Dube
913db1b1ca
std.os.uefi: Fix typo that causes compile time error #22809" 2025-08-21 12:49:34 +02:00
Carl Åstholm
e24d13cae7
Use readStreaming, not readPositional, for streaming file readVec on Windows 2025-08-21 01:20:25 +02:00
Justus Klausecker
43ced7d147 expose darwin.PT in std.c 2025-08-19 16:19:09 -07:00
Carl Åstholm
8af682b13a Fix bugs in Windows readVec implementations 2025-08-19 16:19:06 -07:00
TemariVirus
c3aa650646 std.Io.Writer: fix upper case hex float formatting 2025-08-19 16:01:45 -07:00
Rohlem
6cdbf4223c never advance seek position in std.Io.Reader.peekDelimiterExclusive (#24899)
* extend std.Io.Reader.peekDelimiterExclusive test to repeat successful end-of-stream path (fails)

* fix std.Io.Reader.peekDelimiterExclusive to not advance seek position in successful end-of-stream path
2025-08-19 16:01:40 -07:00
Andrew Kelley
89c9282d34 std.http.Client: discard response body when reusing connection
When an error response was encountered, such as 404 not found, the body
wasn't discarded, leading to the string "404 not found" being
incorrectly interpreted as the next request's response.

closes #24732
2025-08-18 17:26:55 -07:00
Giuseppe Cesarano
b734d03340
Expanded std.os.linux perf-related definitions (#24264)
* Added perf_event_header definition

* Added perf_event_mmap_page definition

* Removed default values for perf_event_header

* Fixed comments typos

* Updated perf_event_attr definition

* Explicit packet struct type

* PERF.RECORD from struct to enum

* fix typo: miscs to misc

* misc as packed struct

* cpu_mode as named enum

* Rescoping CPU_MODE
2025-08-18 21:32:44 +00:00
Isaac Freund
c315f2bc2e http.BodyWriter: improve clarity of chunked state machine
This is theoretically a bugfix as well, since it enforces the correct
limit on the first write after writing the header. This theoretical bug
hasn't been hit in practice though as far as I know.
2025-08-17 14:42:57 +02:00
Andrew Kelley
623290ea9b
Merge pull request #24864 from ifreund/fix-std-cmd
http.BodyWriter: handle EOF in chunkedSendFile, simplify
2025-08-16 16:24:11 -07:00
Isaac Freund
551e009da7 Build.Step.Run: fix missing stdin buffer and flush
Writer.sendFileAll() asserts non-zero buffer capacity in the case that
the fallback is hit. It also requires the caller to flush. The buffer
may be bypassed as an optimization but this is not a guarantee.

Also improve the Writer documentation and add an earlier assert on
buffer capacity in sendFileAll().
2025-08-16 15:43:48 -07:00
Andrew Kelley
399bace2f2
Merge pull request #24874 from ziglang/tls-client
std: more reliable HTTP and TLS networking
2025-08-16 14:47:52 -07:00
Andrew Kelley
ef14c73245 Compilation: remove last instance of deprecatedReader
This also makes initStreaming preemptively disable file size checking.
2025-08-16 14:46:20 -07:00
Isaac Freund
0cfd07bc86
http.BodyWriter: handle EOF in chunkedSendFile, simplify
With these changes, the `zig std` command now works again and doesn't
trigger assertion failures or mess up the chunked transfer encoding.
2025-08-16 22:07:16 +02:00
Josh Wolfe
4fcdb08390 [std] fix compile error in std.Io.Writer.failing 2025-08-16 00:23:47 -07:00
Özgür Akkurt
99c4890559
implement registering NAPI on IoUring (#24850) 2025-08-16 09:18:49 +02:00
Andrew Kelley
a0f9a5e78d std: more reliable HTTP and TLS networking
* std.Io.Reader: fix confused semantics of rebase. Before it was
  ambiguous whether it was supposed to be based on end or seek. Now it
  is clearly based on seek, with an added assertion for clarity.

* std.crypto.tls.Client: fix panic due to not enough buffer size
  available. Also, avoid unnecessary rebasing.

* std.http.Reader: introduce max_head_len to limit HTTP header length.
  This prevents crash in underlying reader which may require a minimum
  buffer length.

* std.http.Client: choose better buffer sizes for streams and TLS
  client. Crucially, the buffer shared by HTTP reader and TLS client
  needs to be big enough for all http headers *and* the max TLS record
  size. Bump HTTP header size default from 4K to 8K.

fixes #24872

I have noticed however that there are still fetch problems
2025-08-16 00:16:15 -07:00
Ryan Liptak
98547713a3 zstd: Protect against index out-of-bounds when decoding sequences
Previously, index out-of-bounds could occur when copying match_length bytes while decoding whatever sequence happened to overflow `dest`. Now, each sequence checks that there is enough room for the full sequence_length (literal_length + match_length) before doing any copying.

Fixes the failing inputs found here: https://github.com/ziglang/zig/issues/24817#issuecomment-3192927715
2025-08-15 22:11:51 -07:00
Rue
ee85c8b6d0
re-enable std.math.modf vector tests (#24786)
* re-enable std.math.modf vector tests
* re-disable std.math.modf vector tests for `aarch64-macos`
* re-disable for s390x architecture
2025-08-16 02:36:09 +00:00
mlugg
d835a6ba9a std.Build: improve error for peak RSS exceeding declared value
As well as the exact byte count, include a human-readable value so it's
clearer what the error is actually telling you. The exact byte count
might not be worth keeping, but I decided I would in case it's useful in
any scenario.
2025-08-15 23:03:16 +01:00
Fri3dNstuff
f758b97bfd
std.math: Add splat for vectors of u0s in rotl/rotr (#24822) 2025-08-15 23:45:33 +02:00
Manlio Perillo
39aca6f37e zon: Add anonymous struct literal in the example 2025-08-15 23:35:16 +02:00