[MONGOCRYPT-343] Audit integer narrowing conversions Created: 11/Oct/21  Updated: 30/Mar/22

Status: Backlog
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.

Generated at Thu Feb 08 09:08:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.