You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "dieortin (via GitHub)" <gi...@apache.org> on 2024/08/28 09:29:57 UTC

[PR] Fix undefined behavior on ElemStack [xerces-c]

dieortin opened a new pull request, #59:
URL: https://github.com/apache/xerces-c/pull/59

   The Undefined Behavior Sanitizer detects undefined behavior in `ElemStack::expandStack`. This is due to `memcpy` being called with NULL as one of its parameters when `toExpand->fMap` is NULL, which works (the size parameter is 0) but is undefined behavior.
   
   This is fixed by doing a simple check for null before calling `memcpy`. If the object we wanted to copy from was null, we do not copy at all and the result is the same. This avoids the UBSan being triggered, and potential issues with compiler optimizations (as both pointer arguments to `memcpy` are marked as `__nonnull`)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "scantor (via GitHub)" <gi...@apache.org>.
scantor commented on PR #59:
URL: https://github.com/apache/xerces-c/pull/59#issuecomment-2315126403

   This is not a GitHub-based project. Bugs and patches should go to issues.apache.org.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "dieortin (via GitHub)" <gi...@apache.org>.
dieortin commented on PR #59:
URL: https://github.com/apache/xerces-c/pull/59#issuecomment-2321276154

   @scantor thanks for the heads up, I'll close this PR then


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "dieortin (via GitHub)" <gi...@apache.org>.
dieortin closed pull request #59: Fix undefined behavior on ElemStack
URL: https://github.com/apache/xerces-c/pull/59


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "scantor (via GitHub)" <gi...@apache.org>.
scantor commented on PR #59:
URL: https://github.com/apache/xerces-c/pull/59#issuecomment-2326490809

   This does look legitimate so please do file it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "scantor (via GitHub)" <gi...@apache.org>.
scantor commented on PR #59:
URL: https://github.com/apache/xerces-c/pull/59#issuecomment-2369004350

   I think this is more of a theoretical issue, I doubt these code paths can run if the initial maps are null.
   
   I would also question why the expandStack methods aren't subject to the same concern.
   
   But I'll apply the two changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "scantor (via GitHub)" <gi...@apache.org>.
scantor commented on PR #59:
URL: https://github.com/apache/xerces-c/pull/59#issuecomment-2369008214

   Applied to 3.3 branch, you can close. I do think it's missing the other case, but I don't think either case was actually "real".


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [PR] Fix undefined behavior on ElemStack [xerces-c]

Posted by "dieortin (via GitHub)" <gi...@apache.org>.
dieortin commented on PR #59:
URL: https://github.com/apache/xerces-c/pull/59#issuecomment-2344126723

   @scantor filed under https://issues.apache.org/jira/browse/XERCESC-2253


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org