• [ace-users] Division by zero in ACE_Stats::quotient() method

    From Johnny Willemsen@21:1/5 to Vural, Okan on Thu Oct 1 09:05:13 2015
    To: ace-users@list.isis.vanderbilt.edu (ace-users@list.isis.vanderbilt.edu)

    Hi,

    Please always use the PRF form, that always helps. The ACE code is not maintained anymore through svn, it is all on github, see https://github.com/DOCGroup/ATCD/.

    Could you extend one of our unit tests under ACE_wrappers/tests (or add
    a new one) and create a pull request which resolves this issue. Maybe
    for this kind of problems it can also help to check the Coverity results
    for ATCD, see https://scan.coverity.com/projects/1

    Best regards,

    Johnny Willemsen
    Remedy IT

    On 10/01/2015 09:00 AM, Vural, Okan wrote:
    Hello All,

    In the both “ACE_Stats::quotient” methods there seems a potential division by zero problem (See below). It is independent of platform,
    this is why I didn’t send the problem in a Problem Report. And I checked the latest version in ACE SVN as well. It seems still same in the latest version.

    *ACE Version **:* V 630
    *File :* Stats.cpp
    *Method **:*

    *void*
    *ACE_Stats::quotient* (*const* ACE_UINT64 dividend,
    *const* ACE_UINT32 divisor,
    ACE_Stats_Value &quotient)
    {
    // The whole part of the division comes from simple integer division.
    quotient.whole (*static_cast*<ACE_UINT32> (divisor == 0
    ? 0 : dividend / divisor));

    *if* (quotient.precision () > 0 *|| divisor == 0*)
    {
    *const* ACE_UINT32 field = quotient.fractional_field ();

    quotient.fractional (*static_cast*<ACE_UINT32> (
    dividend % divisor * field / *divisor*));

    With best regards,
    Okan Vural



    _______________________________________________
    ace-users mailing list
    ace-users@list.isis.vanderbilt.edu http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/ace-users


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vural, Okan@21:1/5 to All on Thu Oct 1 07:00:02 2015
    Hello All,

    In the both "ACE_Stats::quotient" methods there seems a potential division by zero problem (See below). It is independent of platform, this is why I didn't send the problem in a Problem Report. And I checked the latest version in ACE SVN as well. It
    seems still same in the latest version.

    ACE Version : V 630
    File : Stats.cpp
    Method :

    void
    ACE_Stats::quotient (const ACE_UINT64 dividend,
    const ACE_UINT32 divisor,
    ACE_Stats_Value &quotient)
    {
    // The whole part of the division comes from simple integer division.
    quotient.whole (static_cast<ACE_UINT32> (divisor == 0
    ? 0 : dividend / divisor));

    if (quotient.precision () > 0 || divisor == 0)
    {
    const ACE_UINT32 field = quotient.fractional_field ();
    ...
    quotient.fractional (static_cast<ACE_UINT32> (
    dividend % divisor * field / divisor));

    With best regards,
    Okan Vural


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
    <meta name="Generator" content="Microsoft Exchange Server">
    <!-- converted from rtf -->
    <style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
    </head>
    <body>
    <font face="Arial" size="2"><span style="font-size:10pt;">
    <div>Hello All,</div>
    <div><font face="Calibri" size="2"><span style="font-size:11pt;">&nbsp;</span></font></div>
    <div>In the both &#8220;ACE_Stats::quotient&#8221; methods there seems a potential division by zero problem (See below). It is independent of platform, this is why I didn&#8217;t send the problem in a Problem Report. And I checked the latest version in
    ACE SVN as well. It seems
    still same in the latest version.</div>
    <div><font face="Calibri" size="2"><span style="font-size:11pt;">&nbsp;</span></font></div>
    <div><b>ACE Version&nbsp;&nbsp;&nbsp;&nbsp; </b><b>:</b> V 630</div> <div><b>File&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</b> Stats.cpp</div>
    <div><b>Method&nbsp; </b><b>:</b></div>
    <div><font face="Calibri" size="2"><span style="font-size:11pt;">&nbsp;</span></font></div>
    <div><font face="Consolas" color="#7F0055"><b>void</b></font></div>
    <div><font face="Consolas"><b>ACE_Stats::quotient</b> (<font color="#7F0055"><b>const</b></font> <font color="#005032">ACE_UINT64</font> dividend,</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#7F0055"><b>const</b></font> ACE_UINT32 divisor,</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#005032">ACE_Stats_Value</font> &amp;quotient)</font></div>
    <div><font face="Consolas">{</font></div>
    <div><font face="Consolas">&nbsp; <font color="#3F7F5F">// The whole part of the division comes from simple integer division.</font></font></div>
    <div><font face="Consolas">&nbsp; quotient.whole (<font color="#7F0055"><b>static_cast</b></font>&lt;ACE_UINT32&gt; (divisor == 0</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp; ?&nbsp; 0&nbsp; :&nbsp; dividend / divisor));</font></div>
    <div><font face="Calibri" size="2"><span style="font-size:11pt;">&nbsp;</span></font></div>
    <div><font face="Consolas">&nbsp; <font color="#7F0055"><b>if</b></font> (quotient.precision () &gt; 0&nbsp; <b>||&nbsp; divisor == 0</b>)</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp; {</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#7F0055"><b>const</b></font> ACE_UINT32 <span style="background-color:yellow;">field</span> = quotient.fractional_field ();</font></div>
    <div><font face="Consolas">&#8230;</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; quotient.fractional (<font color="#7F0055"><b>static_cast</b></font>&lt;ACE_UINT32&gt; (</font></div>
    <div><font face="Consolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dividend % divisor * <span style="background-color:silver;"
    field</span> / <b>divisor</b>));</font></div>
    <div><font face="Calibri" size="2"><span style="font-size:11pt;">&nbsp;</span></font></div>
    <div>With best regards,</div>
    <div>Okan Vural</div>
    <div><font face="Calibri" size="2"><span style="font-size:11pt;">&nbsp;</span></font></div>
    </span></font>
    </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vural, Okan@21:1/5 to All on Thu Oct 1 07:15:15 2015
    To: ace-users@list.isis.vanderbilt.edu (ace-users@list.isis.vanderbilt.edu)

    SGVsbG8gSm9obm55LA0KDQpJIGRpZG4ndCBrbm93IHlvdSBzd2l0Y2hlZCB0byBHSVQuIFRoYW5r IHlvdSBmb3IgdGhlIEluZm8uDQoNCkFueXdheSwgUHJvYmxlbSBpcyBvYnZpb3VzIGFuZCBtZXRo b2RzIHNlZW0gdW5jaGFuZ2VkIChMaW5lcyAyNzYgYW5kIDMwNykgOiBodHRwczovL2dpdGh1Yi5j b20vRE9DR3JvdXAvQVRDRC9ibG9iL21hc3Rlci9BQ0UvYWNlL1N0YXRzLmNwcA0KV2UgZG9u4oCZ dCB1c2UgJiBjYWxsIFN0YXRzIG1ldGhvZHMuIFdlIGRvbuKAmXQgaGF2ZSB1bml0IHRlc3RzIGVp dGhlci4gUHJvYmxlbSB3YXMgZGV0ZWN0ZWQgYnkgb3VyIFN0YXRpYyBDb2RlIEFuYWx5c2lzIFRv b2wuIEl0IGNhbiBjbGVh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rp ZW50Lndob2xlICgqc3RhdGljX2Nhc3QqPEFDRV9VSU5UMzI+IChkaXZpc29yID09IDANCj4gICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gIDAgIDogIGRpdmlkZW5k IC8gDQo+IGRpdmlzb3IpKTsNCj4gIA0KPiAgICppZiogKHF1b3RpZW50LnByZWNpc2lvbiAoKSA+ IDAgICp8fCAgZGl2aXNvciA9PSAwKikNCj4gICAgIHsNCj4gICAgICAgKmNvbnN0KiBBQ0VfVUlO VDMyIGZpZWxkID0gcXVvdGllbnQuZnJhY3Rpb25hbF9maWVsZCAoKTsg4oCmDQo+ICAgICAgIHF1 b3RpZW50LmZyYWN0aW9uYWwgKCpzdGF0aWNfY2FzdCo8QUNFX1VJTlQzMj4gKA0KPiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIGRpdmlkZW5kICUgZGl2aXNvciAqIGZpZWxkIC8gKmRpdmlz b3IqKSk7DQo+ICANCj4gV2l0aCBiZXN0IHJlZ2FyZHMsDQo+IE9rYW4gVnVyYWwNCj4gIA0KPiAN Cj4gDQo+IF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fDQo+ IGFjZS11c2VycyBtYWlsaW5nIGxpc3QNCj4gYWNlLXVzZXJzQGxpc3QuaXNpcy52YW5kZXJiaWx0 LmVkdQ0KPiBodHRwOi8vbGlzdC5pc2lzLnZhbmRlcmJpbHQuZWR1L2NnaS1iaW4vbWFpbG1hbi9s aXN0aW5mby9hY2UtdXNlcnMNCj4gDQo=

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)