Skip to content

Fix work_dir validation in umount() to guard all uses, not just rmdir#1139

Merged
zhblue merged 2 commits intoAI-patch-2from
copilot/sub-pr-1138
Mar 25, 2026
Merged

Fix work_dir validation in umount() to guard all uses, not just rmdir#1139
zhblue merged 2 commits intoAI-patch-2from
copilot/sub-pr-1138

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

The work_dir safety guard in umount() was placed only around the trailing rmdir calls, leaving earlier uses of work_dirchdir(), strlen(), and multiple execute_cmd() calls (which invoke system()) — completely unprotected against NULL or shell-injectable input.

Changes

  • Early-return guard: Moved the NULL, empty-string, and space-character validation to the top of umount() before any use of work_dir
  • Removed redundant guards: Dropped the inner strlen check and the late if block around rmdir; the single upfront check now covers the entire function body
void umount(char *work_dir)
{
    if (work_dir == NULL || strlen(work_dir) == 0 || strchr(work_dir, ' ') != NULL) return;
    if(chdir(work_dir)) exit(-1);
    execute_cmd("/bin/umount -l %s/usr 2>/dev/null", work_dir);
    // ... all subsequent uses of work_dir are now guarded
}

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI changed the title [WIP] [WIP] Address changes based on feedback from PR #1138 review Fix work_dir validation in umount() to guard all uses, not just rmdir Mar 25, 2026
Copilot AI requested a review from zhblue March 25, 2026 03:33
@zhblue zhblue marked this pull request as ready for review March 25, 2026 04:17
@zhblue zhblue merged commit 82dde22 into AI-patch-2 Mar 25, 2026
2 checks passed
zhblue added a commit that referenced this pull request Mar 25, 2026
* Add files via upload

* Fix formatting in judge_client.cc debug prints

* Update trunk/core/judge_client/judge_client.cc

Co-authored-by: Copilot <[email protected]>

* Update trunk/core/judge_client/judge_client.cc

Co-authored-by: Copilot <[email protected]>

* Fix work_dir validation in umount() to guard all uses, not just rmdir (#1139)

* Initial plan

* Move work_dir validation to start of umount() before any use

Co-authored-by: zhblue <[email protected]>
Agent-Logs-Url: https://github.com/zhblue/hustoj/sessions/1074fa3b-637f-456a-ad51-6cc660b292c9

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: zhblue <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: zhblue <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants