Skip to content

Add files via upload#1138

Merged
zhblue merged 5 commits intomasterfrom
AI-patch-2
Mar 25, 2026
Merged

Add files via upload#1138
zhblue merged 5 commits intomasterfrom
AI-patch-2

Conversation

@zhblue
Copy link
Copy Markdown
Owner

@zhblue zhblue commented Mar 25, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 25, 2026 03:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates judge_client.cc to tighten cleanup behavior around work_dir, fix an incorrect strstr check when handling NOIP output filenames, and adjust ARM64 register debug printing.

Changes:

  • Adjust ARM64 register debug output formatting in print_arm_regs.
  • Add basic work_dir/userfile validation gates before running rmdir/rm shell commands.
  • Fix strstr to check the actual noip_file_name value rather than a string literal, and add an early-return guard in clean_workdir.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

void print_arm_regs(long long unsigned int *d){
for(int i=0;i<32;i++){
printf("[%d]:%llu ",i,d[i]%CALL_ARRAY_SIZE);
printf("[%d]:%lld ",i,d[i]%CALL_ARRAY_SIZE);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

print_arm_regs takes long long unsigned int* but uses %lld to print d[i] % CALL_ARRAY_SIZE. This is a format/argument type mismatch (should be unsigned, e.g. %llu or PRIu64 after casting) and can print incorrect values / trigger UB on some platforms.

Suggested change
printf("[%d]:%lld ",i,d[i]%CALL_ARRAY_SIZE);
printf("[%d]:%llu ", i, (unsigned long long)(d[i] % CALL_ARRAY_SIZE));

Copilot uses AI. Check for mistakes.
Comment on lines +1541 to +1544
if (work_dir != NULL && strlen(work_dir) > 0 && strchr(work_dir, ' ') == NULL) {
execute_cmd("/bin/rmdir %s/* ", work_dir);
execute_cmd("/bin/rmdir %s/log/* ", work_dir);
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The new work_dir guard only wraps the rmdir calls, but umount() already uses work_dir earlier in chdir(work_dir), strlen(work_dir), and multiple execute_cmd("...%s...", work_dir) calls. If work_dir can be NULL/unsafe, this check is ineffective (and chdir/strlen may crash); if the goal is to reduce shell injection risk, validating/escaping work_dir (or avoiding system() entirely) needs to happen before any use of it.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +2207 to +2209
if (strlen(userfile) > 0 && strchr(userfile, ' ') == NULL) {
execute_cmd("rm %s",userfile);
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

execute_cmd("rm %s", userfile) builds a shell command via system() without quoting/escaping userfile. Since userfile includes basename(noip_file_name) read from output.name, a crafted value containing shell metacharacters (e.g. ;, $(...), backticks) could lead to command injection. Prefer deleting via unlink()/remove() (no shell), or at minimum ensure robust escaping/quoting (spaces-only checks are not sufficient).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

@zhblue I've opened a new pull request, #1139, to work on those changes. Once the pull request is ready, I'll request review from you.

@zhblue zhblue merged commit 6f11b9e into master Mar 25, 2026
8 checks passed
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.

3 participants