Skip to content

{Storage} Fix Issues 32147 Add condition checking to avoid infinite loop - #34173

Open
JiaSeng-v wants to merge 2 commits into
Azure:devfrom
JiaSeng-v:fix/issues_32147
Open

JiaSeng-v wants to merge 2 commits into
Azure:devfrom
JiaSeng-v:fix/issues_32147

Conversation

@JiaSeng-v

@JiaSeng-v JiaSeng-v commented Oct 6, 2026 •

Copy link
Copy Markdown

Related command
az storage file upload-batch

Description
Fix #32147 az storage file upload-batch: Fix infinite loop/crash when --destination-path is an absolute path

_make_directory_in_files_share() climbs parent directories using os.path.dirname() until it returns a falsy value. For an absolute path, dirname() returns the root itself forever (e.g. 'C:/' -> 'C:/', '/' -> '/'), so the loop never terminated — the parents list grew unbounded, consuming memory until the process crashed with MemoryError. This was reported with git bash, which silently expands a leading / (e.g. /some/path) into an absolute path (e.g. C:/Program Files/Git/some/path) before the CLI ever sees it, but the bug affects any absolute --destination-path regardless of shell.

Fix: stop the loop once dirname() stops making progress (i.e. returns the same path as the last one recorded), instead of relying on it eventually becoming empty.

Testing Guide

az storage file upload-batch --destination --source --destination-path "/some/path" --account-key

Should complete normally (creating /some/path at the share root) instead of hanging/crashing with MemoryError.

History Notes

[Storage] Fix #32147: az storage file upload-batch: Fix infinite loop/crash when --destination-path is an absolute path


This checklist is used to make sure that common guidelines for a pull request are followed.

@JiaSeng-v
JiaSeng-v requested a review from a team as a code owner October 6, 2026 05:57
Copilot AI balanced review requested due to automatic review settings October 6, 2026 05:57
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Root paths are still created as directories, expanded Git Bash paths remain invalid, and regression coverage is missing.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Prevents unbounded parent traversal during Storage file batch uploads.

Changes:

  • Stops directory traversal when dirname() reaches a fixed point.
File Description
storage/​operations/​file.py Adds termination logic for absolute paths.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

parents = [directory_path]
p = os.path.dirname(directory_path)
while p:
while p and p != parents[-1]:
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@JiaSeng-v JiaSeng-v changed the title Fix Issues 32147: Add condition checking to avoid infinite loop {Storage} Fix Issues 32147 Add condition checking to avoid infinite loop Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leak and crash in git bash if --destination-path is pefixed with a / for az storage file upload-batch

5 participants