Repository navigation
Don't truncate long commands in r_sys_cmdf and r_sys_cmd_strf ##util - #27303
Merged
Merged
Conversation
Collaborator
|
Nice scary limit. Thanks for solving it out! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #27287.
r_sys_cmdfandr_sys_cmd_strfformatted into achar cmd[4096]and ignored whatvsnprintfreturned, so a longer command line was cut at 4095 bytes and whatever was left still ran. The effect depends on where the cut falls:shrejects the whole command, sor_file_copyandr_file_movefail when the two escaped paths add up to more than 4 KiB.shruns a shorter command, for example one without its trailing> fileredirection.Both now format with
r_str_newvfand free the string after running it. They return -1 or NULL if formatting or the allocation fails, where master ran whatever was in the buffer. They do the same for a NULLfmt, asr_core_cmdfdoes.On Windows,
r_sys_cmd_strfcan now pass command lines longer than 32 KiB tor_sys_create_child_proc_w32. #27302 fixes the buffer size there.Testing
test_sys_cmdf_longintest/unit/test_util.cpasses a 5000-byte argument through both:r_sys_cmdfwith a redirection after it, andr_sys_cmd_strfcapturing the output. I built with./configure && makeon Linux (gcc). On master the test fails at "r_sys_cmdf keeps the redirection after a long argument". With this change it passes, along with the rest oftest_util. The other unit tests pass except the nine that need radare2-testbins orradare2in PATH.sys/lint.py --allandgit diff --checkare clean.