Skip to content

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

Merged
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
cmstein:reparam_fix
Jun 12, 2025
Merged

check for errors in ShadingSystem::ReParameter()#1998
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
cmstein:reparam_fix

Conversation

@cmstein

@cmstein cmstein commented Jun 10, 2025

Copy link
Copy Markdown
Collaborator

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.

@lgritz lgritz left a comment

Copy link
Copy Markdown
Collaborator

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

Copilot AI left a comment

Copy link
Copy Markdown

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>

@lgritz lgritz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lgritz
lgritz merged commit 8bc38f4 into AcademySoftwareFoundation:main Jun 12, 2025
25 checks passed
lgritz pushed a commit to lgritz/OpenShadingLanguage that referenced this pull request Jul 2, 2025
…eFoundation#1998)

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.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
@lgritz lgritz added the bug Crash or wrong behavior of an existing feature. label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Crash or wrong behavior of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants