commit 9e61ba19e9cda344aa2094e9a671d98076164163 (tree)
parent 028f2ed30f3318fbe1d2274962d7cda111c695b6
Author: mlugg <mlugg@mlugg.co.uk>
Date: Mon, 12 Jun 2023 22:00:56 +0100
std.crypto.tls.Client: fix @memcpy crash in limitedOverlapCopy
Resolves: #15928
Diffstat:
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/std/crypto/tls/Client.zig b/lib/std/crypto/tls/Client.zig
@@ -1256,10 +1256,8 @@ fn limitedOverlapCopy(frag: []u8, in: usize) void {
// A single, non-overlapping memcpy suffices.
@memcpy(frag[0..first.len], first);
} else {
- // Need two memcpy calls because one alone would overlap.
- @memcpy(frag[0..in], first[0..in]);
- const leftover = first.len - in;
- @memcpy(frag[in..][0..leftover], first[in..][0..leftover]);
+ // One memcpy call would overlap, so just do this instead.
+ std.mem.copyForwards(u8, frag, first);
}
}