<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:04:27 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-43909] util/hex.h is non-portable, inefficient, arbitrary, untested, nonorthogonal, and redundant</title>
                <link>https://jira.mongodb.org/browse/SERVER-43909</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Numerous issues here.&lt;/p&gt;

&lt;p&gt;Need a decomposed library, probably just a set of fundamental templates and some sugar to bind them together into a reasonable user-level offering. Currently we can only parse to std::string and StatusWith&amp;lt;...&amp;gt;, which are too high-level and can&apos;t be fast.&lt;/p&gt;

&lt;p&gt;False advertising: header is missing definition for unconstrained template integerToHex, which is defined in the .cpp file for only a few types. `template &amp;lt;typename T&amp;gt; std::string integerToHex&amp;lt;T&amp;gt;(T);` Calling with an unsupported integer type (like unsigned char or unsigned short) is a link-time error, which is user-unfriendly and undocumented. A header should declare what it provides and only what it provides. After doing some refactoring, I don&apos;t see a reason to have a .cpp file here at all.&lt;/p&gt;

&lt;p&gt;integerToHex formats ALL the bits of the input value and then truncates the leading zeros. This is wasteful.&lt;/p&gt;

&lt;p&gt;integerToHex performs right-shifts on potentially negative integers. This is implementation-defined behavior and not portable.&lt;/p&gt;

&lt;p&gt;Arbitrary: A few of the functions here are doing the same basic thing but with slightly different behavior. For example, hexdump and toHexLower both take a ptr+len and hexdump the memory, but hexdump uses uppercase and spaces between the hexpairs,  while toHexLower uses lowercase and no spaces. hexdump is verify()-limited to 1M bytes, but toHexLower is unlimited. &lt;/p&gt;

&lt;p&gt;isValidHex insists on even digit counts. This is user specific. An unpadded hexdump of an integer value can easily have an odd number of digits (e.g. &quot;0&quot;). Function is unnecessary and called only twice.&lt;/p&gt;

&lt;p&gt;Inefficient: uses various mechanisms internally, inconsistently, of various levels of inefficiency.  These are local char[] + snprintf, StringBuilder, etc.&lt;/p&gt;

&lt;p&gt;There are no unit tests for some of the functions here.&lt;br/&gt;
I introduced some errors and didn&apos;t see any failures in util_test&lt;/p&gt;</description>
                <environment></environment>
        <key id="965719">SERVER-43909</key>
            <summary>util/hex.h is non-portable, inefficient, arbitrary, untested, nonorthogonal, and redundant</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="billy.donahue@mongodb.com">Billy Donahue</assignee>
                                    <reporter username="billy.donahue@mongodb.com">Billy Donahue</reporter>
                        <labels>
                    </labels>
                <created>Wed, 9 Oct 2019 13:46:36 +0000</created>
                <updated>Sun, 29 Oct 2023 22:16:17 +0000</updated>
                            <resolved>Tue, 15 Sep 2020 13:34:33 +0000</resolved>
                                                    <fixVersion>4.8.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="3450546" author="billy.donahue" created="Sat, 17 Oct 2020 01:21:13 +0000"  >&lt;p&gt;Discussed with Geert.&lt;br/&gt;
There are two calls to &lt;tt&gt;hexblob::encode&lt;/tt&gt; that are passed a raw bsondata&apos;s data and length.&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;bson/bsonelement.cpp:876&amp;#93;&lt;/span&gt; &lt;tt&gt;BSONElement::toString()&lt;/tt&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;db/cst/c_node.cpp:123&amp;#93;&lt;/span&gt; &lt;tt&gt;printValue&amp;lt;T&amp;gt;&lt;/tt&gt;, a helper of &lt;tt&gt;CNode::toString&lt;/tt&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The bug here is that hexblob::encode takes size_t len and the old toHex took int len.&lt;/p&gt;

&lt;p&gt;The length of a BSONElement&apos;s binData type 2 payload can actually be computed to be negative if the BSON is malformed.&lt;/p&gt;

&lt;p&gt;The length of a binData has 4 subtracted if that binData is type 2, because there&apos;s assumed to be a 4 byte redundant length in the type2 payload. But the presence of this redundant length is not actually checked, so we can return a negative length.&lt;/p&gt;

&lt;p&gt;Diagnostics like toString should not be causing crashes. We can clamp the len to a lowerbound of 0 before calling hexblob::encode&lt;/p&gt;</comment>
                            <comment id="3393753" author="xgen-internal-githook" created="Tue, 15 Sep 2020 00:42:15 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-43909&quot; title=&quot;util/hex.h is non-portable, inefficient, arbitrary, untested, nonorthogonal, and redundant&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-43909&quot;&gt;&lt;del&gt;SERVER-43909&lt;/del&gt;&lt;/a&gt; clarify and repair util/hex.h API&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;hexblob namespace&lt;/li&gt;
	&lt;li&gt;Throwy hexblob::decode (nee fromHex)&lt;/li&gt;
	&lt;li&gt;StringData overloads of hex codec ops&lt;/li&gt;
	&lt;li&gt;add unsignedHex&amp;lt;T&amp;gt; and zeroPaddedHex&amp;lt;T&amp;gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/58828b0ce9556ee9cb38c484d1226663a0dcd993&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/58828b0ce9556ee9cb38c484d1226663a0dcd993&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="3392567" author="billy.donahue" created="Mon, 14 Sep 2020 16:24:57 +0000"  >&lt;p&gt;CR&lt;br/&gt;
&lt;a href=&quot;https://mongodbcr.appspot.com/635470002/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://mongodbcr.appspot.com/635470002/&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2474530" author="billy.donahue" created="Wed, 9 Oct 2019 19:38:27 +0000"  >&lt;p&gt;The fromHex are also unsafe and slow.&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;StatusWith&amp;lt;char&amp;gt; fromHex(const char* c);&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;StatusWith&amp;lt;char&amp;gt; fromHex(StringData c);&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;They don&apos;t actually check that their input has string length of at least 2, so that&apos;s unsafe. They call fromHex(char) to make a StatusWith&amp;lt;char&amp;gt; for each of the 2 chars, and check that result for .isOK(). But then they discard that StatusWith&amp;lt;char&amp;gt;, and call fromHex(char) again, this time calling .getValue().&lt;/p&gt;

&lt;p&gt;Really should be addressed.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                        <issuelink>
            <issuekey id="1517484">SERVER-51719</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1944112">SERVER-61943</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 15 Sep 2020 00:42:15 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 16 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 16 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>billy.donahue@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hvwtyv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hvlctj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="4267">Service arch 2020-09-21</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hvwg87:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>