Skip to content

check for errors in ShadingSystem::ReParameter() #1998

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cmstein
Copy link
Collaborator

@cmstein cmstein commented Jun 10, 2025

Description

ShadingSystem() wasn't checking whether the offset returned by interactive_param_offset() was valid or not before performing the ReParameter() memcpy(). So, we could copy data to a location outside of a valid memory block and cause a crash.

Tests

tests pass except for '987 - render-microfacet.opt (Failed)' but I get the same error for main.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

Code LGTM, though needs a clang-format and I think you didn't DCO-sign the commit.

@lgritz lgritz requested a review from Copilot June 10, 2025 22:45
Copy link

@Copilot Copilot AI left a 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 potential crash in ShadingSystemImpl::ReParameter by checking if the offset returned by interactive_param_offset() is valid before performing a memcpy.

  • Added a condition to verify the offset is non-negative
  • Prevents the memcpy from executing if the offset is invalid
Comments suppressed due to low confidence (1)

src/liboslexec/shadingsys.cpp:3442

  • Returning true when the offset is invalid might be misleading if an invalid offset should indicate a failure. Consider returning false or logging a warning to clearly signal the issue.
else

…rameter

in the live-params records

Signed-off-by: Clifford Stein <cstein@imageworks.com>
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