mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-06 21:37:49 +00:00
Fixes #9579 Protect against panics caused by integer overflows by using functions that allow integer overflows to be caught instead of causing a panic. Also protect against DOS from images that might not cause an overflow but do consume an absurd amount of memory by limiting images to a maximum size of 4GiB (which is the maximum size of `image-storage-limit`).
21 lines
487 B
Zig
21 lines
487 B
Zig
const std = @import("std");
|
|
|
|
pub const png = @import("png.zig");
|
|
pub const jpeg = @import("jpeg.zig");
|
|
pub const swizzle = @import("swizzle.zig");
|
|
pub const Error = @import("error.zig").Error;
|
|
|
|
/// The maximum image size, based on the 4G limit of Ghostty's
|
|
/// `image-storage-limit` config.
|
|
pub const maximum_image_size = 4 * 1024 * 1024 * 1024;
|
|
|
|
pub const ImageData = struct {
|
|
width: u32,
|
|
height: u32,
|
|
data: []u8,
|
|
};
|
|
|
|
test {
|
|
std.testing.refAllDeclsRecursive(@This());
|
|
}
|