<div dir="ltr"><div>Hello cfe-dev,</div><div><br></div><div>I have a patch to fix PR 21254 ( <a href="http://llvm.org/bugs/show_bug.cgi?id=21254">http://llvm.org/bugs/show_bug.cgi?id=21254</a> ).</div><div><br></div><div>The details of the problem are quite complex and explained in the bugzilla entry, but it all boils down to a bitfield being too narrow.</div><div>At the moment it is possible that a client of the Clang library may create enough custom Doxygen-style commands that the comment parser runs out of ID numbers it can use. Even Clang itself is using this registration mechanism to record 'unknown' commands when it encounters them, and therefore a maliciously constructed source code can crash Clang or cause some issues.</div><div><br></div><div>The problem is that this ID bitfield, whose original definition is in CommentInfo class, is also replicated and embedded in other bitfields in the Comment class, and the size of those bitfields is constrained to an unsigned int (32 bits) unless we want to re-engineer the bitfields in the Comment class to be larger.</div><div><br></div><div>So the patch does the following:</div><div>- It extends the ID bitfield from 8 to 20 bits (which is still in the budget).</div><div>- It provides a DRY definition of the number of bits the field has, so that we don't have "magic numbers" that have to agree in CommandInfo and Comment.</div><div>- It introduces an assertion that checks the number of IDs doesn't wrap around.</div><div>- It adds the PR testcase as a Clang regression test that checks we can have more than 256 commands.</div><div><br></div><div>Ideally we should have a test that checks for the maximum number of commands, but with 20 bits we would need a million commands and the test would be megabytes in size.</div><div>I can generate one if you think it's necessary, but I guess that checking in a huge test file is not great.</div><div><br></div><div>Cheers,</div><div>    Dario Domizioli</div><div>    SN Systems - Sony Computer Entertainment Group</div><div><br></div></div>