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

Sanitize filenames when using "archive_groupname" #1383

Merged
merged 2 commits into from
Jul 2, 2021

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Jun 24, 2021

This feature (used, very possibly, only by me, for debugging)
forces OSL to write an archive that contains the oso files and a
serialized version of the shader network.

If no explicit name is given (by the "archive_filename" attribute), it
picks a name based on the shader group name. But that may not be a
safe string for a valid filename. We already eliminated anything
before the last slash, but it turns out that a colon (':') can also
really mess things up. So this small change protects against that.

Signed-off-by: Larry Gritz [email protected]

This feature (used, very possibly, only by me, for debugging) lets me
force OSL to write an archive that contains the oso files and a
serialized version of the shader network.

If no explicit name is given (by the "archive_filename" attribute), it
picks a name based on the shader group name. But that may not be a
safe string for a valid filename. We already eliminated anything
before the last slash, but it turns out that a colon (':') can also
really mess things up. So this small change protects against that.

Signed-off-by: Larry Gritz <[email protected]>
shell commands for tar/zip'ing up group archives.

* Look out for `|` character.

* For the actual commands sent to system(), escape special characters
  in the strings and enclose any arguments that come from the user in
  double quotes. That prevents shenannigans like asking for an archive
  filename called "; rm -r *". By enclosing in double quotes, we'll
  end up with a badly named filename produced by tar, rather than
  possibly an arbitrary command being executed.

Signed-off-by: Larry Gritz <[email protected]>
@lgritz
Copy link
Collaborator Author

lgritz commented Jun 25, 2021

Amended:

Be even more careful with how we assemble the strings used to form
shell commands for tar/zip'ing up group archives.

  • Look out for | character.

  • For the actual commands sent to system(), escape special characters
    in the strings and enclose any arguments that come from the user in
    double quotes. That prevents shenannigans like asking for an archive
    filename called "; rm -r *". By enclosing in double quotes, we'll
    end up with a badly named filename produced by tar, rather than
    possibly an arbitrary command being executed.

@lgritz lgritz merged commit d6ec4b8 into AcademySoftwareFoundation:master Jul 2, 2021
@lgritz lgritz deleted the lg-archive branch July 2, 2021 06:13
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