<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:14:02 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>[CDRIVER-2059] Topology component uses signed and unsigned types for localThresholdMS</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-2059</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.6.0/src/mongoc/mongoc-topology.c#L256&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;mongoc_topology_new()&lt;/tt&gt;&lt;/a&gt; selects the &quot;localThresholdMS&quot; URI option as an &lt;tt&gt;int32_t&lt;/tt&gt;, where it is assigned to an &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.6.0/src/mongoc/mongoc-topology-private.h#L49&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;int64_t&lt;/tt&gt; in the struct field&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From there, it passes the value as an &lt;tt&gt;int64_t&lt;/tt&gt; to &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.6.0/src/mongoc/mongoc-topology-description.c#L741&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;mongoc_topology_description_select()&lt;/tt&gt;&lt;/a&gt;. That &lt;tt&gt;int64_t&lt;/tt&gt; is then passed as an &lt;tt&gt;size_t&lt;/tt&gt; to &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.6.0/src/mongoc/mongoc-topology-description.c#L570&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;mongoc_topology_description_suitable_servers()&lt;/tt&gt;&lt;/a&gt;, which may also call &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.6.0/src/mongoc/mongoc-topology-description.c#L382&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;_mongoc_try_mode_secondary()&lt;/tt&gt;&lt;/a&gt; (also accepting a &lt;tt&gt;size_t&lt;/tt&gt;).&lt;/p&gt;

&lt;p&gt;There seem to be two issues with this:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;A negative &quot;localThresholdMS&quot; option parsed as a signed &lt;tt&gt;int32_t&lt;/tt&gt; would be converted to a negative, signed &lt;tt&gt;int64_t&lt;/tt&gt; value and possibly a very large unsigned &lt;tt&gt;size_t&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;On a 32-bit system, a &lt;tt&gt;int64_t&lt;/tt&gt; is being assigned to a possibly 32-bit &lt;tt&gt;size_t&lt;/tt&gt;. Aside from a possible compiler warning, this might also lead to an unexpected assignment of a negative 64-bit value to an unsigned 32-bit value. I&apos;m uncertain if the sign bit would simply be ignored, etc.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#localthresholdms&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;server selection spec&lt;/a&gt; does not outline a maximum value for &quot;localThresholdMS&quot;, so I presume that is left to implementations. In that event, it might be reasonable to limit it to the maximum value of a signed 32-bit integer and always store it as a &lt;tt&gt;size_t&lt;/tt&gt; after &lt;tt&gt;mongoc_topology_new()&lt;/tt&gt; parses the URI option.&lt;/p&gt;</description>
                <environment></environment>
        <key id="354306">CDRIVER-2059</key>
            <summary>Topology component uses signed and unsigned types for localThresholdMS</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                            <label>neweng</label>
                    </labels>
                <created>Thu, 16 Feb 2017 16:48:15 +0000</created>
                <updated>Mon, 22 Jan 2024 16:11:24 +0000</updated>
                                            <version>1.6.0</version>
                                                    <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="354307">CDRIVER-2060</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr6i7u:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>