[GitHub] [xerces-c] rleigh-codelibre commented on a diff i n pull request #51: [XERCESC-2241] Fix integer overflows in DFAContentModel class
GitBox <[email protected]>
| Newsgroups | gmane.text.xml.xerces-c.devel |
|---|---|
| Message-ID | <PR_kwDODeOUTs5AAzEJ-d2183d6c-9204-454f-9cbc-9a2ce91dd5f0@gitbox.apache.org> |
rleigh-codelibre commented on code in PR #51:
URL: https://github.com/apache/xerces-c/pull/51#discussion_r986046406
##########
src/xercesc/validators/common/DFAContentModel.cpp:
##########
@@ -661,8 +662,15 @@ void DFAContentModel::buildDFA(ContentSpecNode* const curNode)
// in the fLeafCount member.
//
fLeafCount=countLeafNodes(curNode);
+ // Avoid integer overflow in below fLeafCount++ increment
+ if (fLeafCount > std::numeric_limits<unsigned int>::max() - 1)
+ throw OutOfMemoryException();
fEOCPos = fLeafCount++;
+ // Avoid integer overflow in below memory allocatoin
+ if (fLeafCount > std::numeric_limits<size_t>::max() / sizeof(CMLeaf*))
Review Comment:
I just meant `fLeafCount > (std::numeric_limits<size_t>::max() / sizeof(CMLeaf*))` so that the operator precedence is explicit (and the same for below).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]