-
Notifications
You must be signed in to change notification settings - Fork 124
Fixed the vine_factory bug during command line submission #4235
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
base: master
Are you sure you want to change the base?
Fixed the vine_factory bug during command line submission #4235
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that you should try to use functions in dttools/src/stringtools.h if possible.
|
Is there progress in this pr? |
There was a problem hiding this 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 fixes a bug in the vine_factory where special characters in command line arguments were not being properly escaped for POSIX shell submission, causing command execution failures. The fix introduces proper shell escaping by wrapping arguments in double quotes and escaping special characters.
Key changes:
- Added a new
string_escape_shell_vine_factory()function to properly escape shell special characters - Applied shell escaping to
submission_regex,manager_host,worker_command, andscratch_dirparameters in command construction - Removed single quotes around arguments in
cpcommands since the escaping function now handles proper quoting
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Worst case: every char becomes 2 chars + quotes | ||
| char *output = malloc(len * 2 + 3); |
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The memory allocation calculation len * 2 + 3 may be insufficient for strings containing many special characters. Consider using a more conservative calculation or dynamic reallocation to prevent buffer overflows.
| // Worst case: every char becomes 2 chars + quotes | |
| char *output = malloc(len * 2 + 3); | |
| // First pass: calculate required output size | |
| size_t out_len = 2; // for opening and closing quotes | |
| for (const char *src = input; *src; src++) { | |
| switch (*src) { | |
| case '"': | |
| case '\\': | |
| case '$': | |
| case '`': | |
| case '!': | |
| case '\'': | |
| out_len += 2; // escaped char: backslash + char | |
| break; | |
| default: | |
| out_len += 1; | |
| break; | |
| } | |
| } | |
| out_len += 1; // for null terminator | |
| char *output = malloc(out_len); |
| "./%s --parent-death -M %s -t %d -C '%s' %s %s %s %s %s %s %s %s", | ||
| worker_command, | ||
| submission_regex, | ||
| string_escape_shell_vine_factory(submission_regex), |
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak: The strings returned by string_escape_shell_vine_factory() are dynamically allocated but never freed. Store the returned pointers and call free() after string_format() to prevent memory leaks.
| "./%s --parent-death %s %d -t %d -C '%s' %s %s %s %s %s %s %s", | ||
| worker_command, | ||
| manager_host, | ||
| string_escape_shell_vine_factory(manager_host), |
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak: The strings returned by string_escape_shell_vine_factory() are dynamically allocated but never freed. Store the returned pointers and call free() after string_format() to prevent memory leaks.
| if(worker_command != NULL){ | ||
| cmd = string_format("cp '%s' '%s'",worker_command,scratch_dir); | ||
| cmd = string_format("cp %s %s", | ||
| string_escape_shell_vine_factory(worker_command), |
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak: The strings returned by string_escape_shell_vine_factory() are dynamically allocated but never freed. Store the returned pointers and call free() after string_format() to prevent memory leaks.
| string_escape_shell_vine_factory(tmp), | ||
| string_escape_shell_vine_factory(scratch_dir)); |
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak: The strings returned by string_escape_shell_vine_factory() are dynamically allocated but never freed. Store the returned pointers and call free() after string_format() to prevent memory leaks.
Proposed Changes
This PR is for BUG, where the problem is that from the factory, we are submitting the vine_worker command using the command line. When we include any special character, the POSIX command line cannot accept it, so we need to escape them and include a double quote, something like hello'world -> "hello'world" so then the POSIX will accept it. I am attaching with printf command while submitting the one without fix and with fix below for reference. NOTE that the printf is for dev and is not present in PR.
One without any fix

After the fix when we are able to submit the job

Merge Checklist
The following items must be completed before PRs can be merged.
Check these off to verify you have completed all steps.
make testRun local tests prior to pushing.make formatFormat source code to comply with lint policies. Note that some lint errors can only be resolved manually (e.g., Python)make lintRun lint on source code prior to pushing.