Skip to content

rescanMac: Avoid overallocating/overreading by millions of bytes #22928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/std/crypto/Certificate/Bundle/macos.zig
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void {

if (cert_header.cert_size == 0) continue;

try cb.bytes.ensureUnusedCapacity(gpa, cert_header.cert_size);

const cert_start = @as(u32, @intCast(cb.bytes.items.len));
const dest_buf = cb.bytes.allocatedSlice()[cert_start..];
cb.bytes.items.len += try reader.readAtLeast(dest_buf, cert_header.cert_size);
const dest_buf = try cb.bytes.addManyAsSlice(gpa, cert_header.cert_size);
try reader.readNoEof(dest_buf);

try cb.parseCert(gpa, cert_start, now_sec);
}
Expand Down
Loading