Skip to content

Commit a2595f1

Browse files
committed
fix: reject unsafe bash env integers
1 parent 1a926d1 commit a2595f1

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/agents/bash-tools.shared.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ describe("resolveSandboxWorkdir", () => {
3535
expect(readEnvInt("OPENCLAW_BASH_YIELD_MS", "PI_BASH_YIELD_MS")).toBeUndefined();
3636
});
3737

38+
it("ignores unsafe environment integers", () => {
39+
vi.stubEnv("OPENCLAW_BASH_YIELD_MS", "9007199254740993");
40+
41+
expect(readEnvInt("OPENCLAW_BASH_YIELD_MS", "PI_BASH_YIELD_MS")).toBeUndefined();
42+
});
43+
3844
it("maps container root workdir to host workspace", async () => {
3945
await withTempDir(async (workspaceDir) => {
4046
const warnings: string[] = [];

src/agents/bash-tools.shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export function readEnvInt(key: string, legacyKey?: string) {
214214
return undefined;
215215
}
216216
const parsed = Number(trimmed);
217-
return Number.isFinite(parsed) ? parsed : undefined;
217+
return Number.isSafeInteger(parsed) ? parsed : undefined;
218218
}
219219

220220
export function chunkString(input: string, limit = CHUNK_LIMIT) {

0 commit comments

Comments
 (0)