Repository navigation
Fix EISDIR warnings and Max Stack Size errors for issue #21527 #25444
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
Changes from 3 commits
657e630
d3481c9
ea51c67
96a80eb
382e95b
f22a6de
a66b75e
d798185
8ca46e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,3 +64,6 @@ gemini-debug.log | |
| evals/logs/ | ||
|
|
||
| temp_agents/ | ||
| PR.md | ||
| changes.md | ||
| pr_body.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,7 @@ interface HandleAtCommandParams { | |
| messageId: number; | ||
| signal: AbortSignal; | ||
| escapePastedAtSymbols?: boolean; | ||
| depth?: number; | ||
| } | ||
|
|
||
| interface HandleAtCommandResult { | ||
|
|
@@ -504,6 +505,9 @@ async function readLocalFiles( | |
| config: Config, | ||
| signal: AbortSignal, | ||
| userMessageTimestamp: number, | ||
| depth: number, | ||
| addItem: UseHistoryManagerReturn['addItem'], | ||
| onDebugMessage: (message: string) => void, | ||
| ): Promise<{ | ||
| parts: PartUnion[]; | ||
| display?: IndividualToolCallDisplay; | ||
|
|
@@ -580,7 +584,25 @@ async function readLocalFiles( | |
| parts.push({ | ||
| text: `\nContent from @${displayPath}:\n`, | ||
| }); | ||
| parts.push({ text: fileActualContent }); | ||
|
|
||
| if (depth < 2 && typeof fileActualContent === 'string' && fileActualContent.includes('@')) { | ||
| const nestedResult = await handleAtCommand({ | ||
| query: fileActualContent, | ||
| config, | ||
| addItem: () => 0, // Mock addItem to prevent history pollution. | ||
| onDebugMessage: () => {}, | ||
| messageId: userMessageTimestamp, | ||
| signal, | ||
| depth: depth + 1, | ||
| }); | ||
| if (nestedResult.processedQuery) { | ||
| parts.push(...nestedResult.processedQuery); | ||
| } else { | ||
| parts.push({ text: fileActualContent }); | ||
| } | ||
| } else { | ||
| parts.push({ text: fileActualContent }); | ||
| } | ||
| } else { | ||
| parts.push({ text: part }); | ||
| } | ||
|
|
@@ -667,7 +689,12 @@ export async function handleAtCommand({ | |
| messageId: userMessageTimestamp, | ||
| signal, | ||
| escapePastedAtSymbols = false, | ||
| depth = 0, | ||
| }: HandleAtCommandParams): Promise<HandleAtCommandResult> { | ||
| if (depth > 2) { | ||
| return { processedQuery: [{ text: query }] }; | ||
| } | ||
|
Comment on lines
+701
to
+703
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The References
|
||
|
|
||
| const commandParts = parseAllAtCommands(query, escapePastedAtSymbols); | ||
|
|
||
| const { agentParts, resourceParts, fileParts } = categorizeAtCommands( | ||
|
|
@@ -710,7 +737,7 @@ export async function handleAtCommand({ | |
|
|
||
| const [mcpResult, fileResult] = await Promise.all([ | ||
| readMcpResources(resourceParts, config, signal), | ||
| readLocalFiles(resolvedFiles, config, signal, userMessageTimestamp), | ||
| readLocalFiles(resolvedFiles, config, signal, userMessageTimestamp, depth, addItem, onDebugMessage), | ||
| ]); | ||
|
|
||
| const hasContent = mcpResult.parts.length > 0 || fileResult.parts.length > 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -287,6 +287,7 @@ export async function isBinaryFile(filePath: string): Promise<boolean> { | |||||
| try { | ||||||
| fh = await fs.promises.open(filePath, 'r'); | ||||||
| const stats = await fh.stat(); | ||||||
| if (stats.isDirectory()) return false; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A Denial of Service (DoS) vulnerability exists in the isBinaryFile function. If the resolved path points to a special file (e.g., named pipe, device file) and is not verified as a regular file before being passed to isBinaryFileCheck, the subsequent read operation could block indefinitely. Additionally, ensure you use asynchronous file system operations (e.g., fs.promises.realpath) instead of synchronous ones to avoid blocking the event loop. This utility should validate its path inputs internally and continue to use resolveToRealPath for consistent path resolution.
Suggested change
References
|
||||||
| const fileSize = stats.size; | ||||||
| if (fileSize === 0) return false; // empty is not binary | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.