Skip to content

[Bug]: CLI has no file size limit — OOM on large files #197

@Splatcrafter

Description

@Splatcrafter

AI REVIEWED

Module: cli
Files: All commands
Severity: High

Summary

Files.readString() loads the entire file into heap. No file size check is performed. A 1GB+ file causes OutOfMemoryError.

Suggested Fix

private static final long MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB

long size = Files.size(inputFile.toPath());
if (size > MAX_FILE_SIZE) {
    throw new IOException("File exceeds maximum size (" + (MAX_FILE_SIZE / 1024 / 1024) + "MB): " + inputFile);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions