Skip to content
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

OSDelegatingFileTailingMessageProducer cannot handle filename having special characters #3507

Closed
trgpa opened this issue Mar 11, 2021 · 0 comments
Assignees
Milestone

Comments

@trgpa
Copy link
Contributor

trgpa commented Mar 11, 2021

I noticed that the way OSDelegatingFileTailingMessageProducer passing command string to Runtime.getRuntime().exec may cause problems if spaces (and other special characters) are used in the filename.

this.command = "tail " + this.options + " " + getFile().getAbsolutePath();

e.g foo bar -c 1 is a valid unix filename. The command would be interpreted as tail <options> /path/foo bar -c 1. This command tails two different files /path/foo and bar with option -c 1.
Just a caveat, command options could be injected because tail command on many linux distros accepts command options to be placed after file path.
I will make a PR for this issue soon.

@trgpa trgpa added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels Mar 11, 2021
@artembilan artembilan self-assigned this Mar 11, 2021
@artembilan artembilan added this to the 5.5 M3 milestone Mar 11, 2021
@artembilan artembilan added backport 5.2.x in: file and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels Mar 11, 2021
artembilan pushed a commit that referenced this issue Mar 11, 2021
Fixes #3507

The `OSDelegatingFileTailingMessageProducer` passing command string to `Runtime.getRuntime().exec()`
may cause problems if spaces (and other special characters) are used in the filename.

* Use an array for command and its options to let the target `Runtime` to parse and
execute it properly

**Cherry-pick to 5.4.x, 5.3.x & 5.2.x**
artembilan pushed a commit that referenced this issue Mar 11, 2021
Fixes #3507

The `OSDelegatingFileTailingMessageProducer` passing command string to `Runtime.getRuntime().exec()`
may cause problems if spaces (and other special characters) are used in the filename.

* Use an array for command and its options to let the target `Runtime` to parse and
execute it properly

**Cherry-pick to 5.4.x, 5.3.x & 5.2.x**

# Conflicts:
#	spring-integration-file/src/main/java/org/springframework/integration/file/tail/OSDelegatingFileTailingMessageProducer.java
artembilan pushed a commit that referenced this issue Mar 11, 2021
Fixes #3507

The `OSDelegatingFileTailingMessageProducer` passing command string to `Runtime.getRuntime().exec()`
may cause problems if spaces (and other special characters) are used in the filename.

* Use an array for command and its options to let the target `Runtime` to parse and
execute it properly

**Cherry-pick to 5.4.x, 5.3.x & 5.2.x**

# Conflicts:
#	spring-integration-file/src/main/java/org/springframework/integration/file/tail/OSDelegatingFileTailingMessageProducer.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants