[GitHub] [xerces-c] rouault commented on a diff in pull re quest #51: [XERCESC-2241] Fix integer overflows in DFACon tentModel class

GitBox <[email protected]>
Newsgroups gmane.text.xml.xerces-c.devel
Message-ID <PR_kwDODeOUTs5AAzEJ-90a4e903-39b3-4826-81da-8fb7fca150d5@gitbox.apache.org>
rouault commented on code in PR #51:
URL: https://github.com/apache/xerces-c/pull/51#discussion_r986050269


##########
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:
   ah sorry for some reason I read your sentence as "would it be possible to *avoid* the division"... Brackets added



-- 
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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.