Skip to content

Fix husk -o/-j argument bounds check in batch command line#2658

Merged
sebastienblor merged 1 commit into
masterfrom
kikou/fix-husk-arg-bounds
May 25, 2026
Merged

Fix husk -o/-j argument bounds check in batch command line#2658
sebastienblor merged 1 commit into
masterfrom
kikou/fix-husk-arg-bounds

Conversation

@kikou

@kikou kikou commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • In HdArnoldRenderDelegate::_SetRenderSetting (batchCommandLine handling), the guard i < commandLine.size() - 2 was off by one: with a valid trailing pair like {"-o", "out.exr"} (size 2, i = 0) the check is 0 < 0 and the override is silently dropped.
  • commandLine.size() is unsigned, so size() - 2 also underflows when size() < 2, which would make i < HUGE trivially true and lead to an out-of-bounds access after ++i.
  • Rewrote both occurrences (-o and -j/--threads) as i + 1 < commandLine.size() — same intent, no off-by-one, no unsigned underflow.

Test plan

  • Render via husk passing -o out.exr and confirm the output path override is applied.
  • Render via husk passing -j N / --threads N and confirm thread count is set on the options node.
  • Sanity-check that an empty / single-element batch command line no longer triggers an OOB read.

The guard "i < commandLine.size() - 2" was off by one and dropped
the valid trailing pair (e.g. {"-o", "out.exr"} of size 2). It also
underflows when commandLine.size() < 2, since size() is unsigned.

Rewrote as "i + 1 < commandLine.size()" so the next-element access
is bounded correctly without unsigned underflow.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a bounds-check bug in HdArnoldRenderDelegate::_SetRenderSetting when parsing Houdini/Solaris batchCommandLine render settings, preventing valid trailing -o <path> and -j/--threads <N> pairs from being ignored and avoiding potential out-of-bounds reads for short arrays.

Changes:

  • Replace i < commandLine.size() - 2 guards with i + 1 < commandLine.size() for -o parsing.
  • Apply the same fix for -j / --threads parsing to prevent unsigned underflow and off-by-one behavior.

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

@sebastienblor sebastienblor merged commit 682c27a into master May 25, 2026
10 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