Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-343

Audit integer narrowing conversions

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None

    Description

      Background
      There are several examples of casts between integral types of mismatched sizes.

      Here is an example:

         kms->msg.len = (uint32_t) strlen (request_string);
      

      This casts the size_t returned by strlen into a uint32_t. The size of size_t is platform dependent.

      Scope

      • Check for all cases of integer conversions that may result in narrowing or undefined behavior.
      • Return an error when possible in cases where the cast would result in unexpected overflow.
      • Investigate whether narrowing conversions can cause an error in Evergreen builds to prevent future regressions.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: