Skip to content

Conversation

@fredroy
Copy link
Contributor

@fredroy fredroy commented Jan 29, 2026

Different overflows risk were not checked,
and one array access is a bug (in BaseContactMapper)

[with-all-tests]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request pr: ai-generated Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Jan 29, 2026
@fredroy fredroy force-pushed the fix_vulnerabilities_overflows branch from cbcd999 to e942da9 Compare January 29, 2026 03:53
@fredroy
Copy link
Contributor Author

fredroy commented Jan 29, 2026

[ci-build][with-all-tests]

@fredroy fredroy force-pushed the fix_vulnerabilities_overflows branch from e942da9 to 6c9a8b2 Compare February 2, 2026 00:11
…reading and writing same buffer).

  Fixed:
  sscanf(buf, "%*127s %127s", matName);

  Breaking down the format:
  - %*127s - The * is the assignment suppression modifier. It means "read up to 127 chars but discard them (don't store)". This skips the first word (like "newmtl")
  - %127s - Read the second word (the material name), limited to 127 chars, store in matName

  So if buf contains "newmtl MyMaterial\n":
  - %*127s reads and discards "newmtl"
  - %127s reads "MyMaterial" into matName

  The 127 limit prevents buffer overflow since matName is 128 bytes (127 chars + null terminator).
… buffer overflows from size calculation wraparound
@fredroy fredroy force-pushed the fix_vulnerabilities_overflows branch from 6c9a8b2 to d79f4e4 Compare February 3, 2026 22:05
Comment on lines +865 to 871
if (lines.empty())
{
m.resize(0, 0);
if( in.rdstate() & std::ios_base::eofbit ) { in.clear(); }
}

m.resize( (Index)lines.size(), (Index)lines[0].size() );
Copy link
Contributor

Choose a reason for hiding this comment

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

I am sorry but I wasn't clear enough. What I really wanted was to keep the compress. It is sufficient to wrap the resize in a if/else statement.

Suggested change
if (lines.empty())
{
m.resize(0, 0);
if( in.rdstate() & std::ios_base::eofbit ) { in.clear(); }
}
m.resize( (Index)lines.size(), (Index)lines[0].size() );
if (lines.empty())
{
m.resize(0, 0);
}
else
{
m.resize( (Index)lines.size(), (Index)lines[0].size() );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: ai-generated Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants