[tor-bugs] #20558 [Core Tor/Tor]: Coverity complains about 64-bit time_t vs 64-bit int64_t comparison

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Nov 3 23:29:20 UTC 2016


#20558: Coverity complains about 64-bit time_t vs 64-bit int64_t comparison
------------------------------+--------------------------------
     Reporter:  nickm         |      Owner:
         Type:  defect        |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: 0.3.0.x-final
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:
Actual Points:                |  Parent ID:
       Points:                |   Reviewer:
      Sponsor:                |
------------------------------+--------------------------------
 {{{
 *** CID 1375988:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
 /src/or/torcert.c: 160 in tor_cert_parse()
 154       cert = tor_malloc_zero(sizeof(tor_cert_t));
 155       cert->encoded = tor_memdup(encoded, len);
 156       cert->encoded_len = len;
 157
 158       memcpy(cert->signed_key.pubkey, parsed->certified_key, 32);
 159       const int64_t valid_until_64 = ((int64_t)parsed->exp_field) *
 3600;
 >>>     CID 1375988:  Integer handling issues
 (CONSTANT_EXPRESSION_RESULT)
 >>>     "valid_until_64 > 9223372036854775807L /*
 (time_t)9223372036854775807L */" is always false regardless of the values
 of its operands. This occurs as the logical operand of if.
 160       if (valid_until_64 > TIME_MAX)
 161         cert->valid_until = TIME_MAX - 1;
 162       else
 163         cert->valid_until = (time_t) valid_until_64;
 164       cert->cert_type = parsed->cert_type;
 165
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/20558>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list