)]}'
{
  "commit": "afd52e91dfed27ab7193be040f067900947b14ac",
  "tree": "d299c683299da0063c5d73af2c6b2a20c4c6cdd4",
  "parents": [
    "e95b0cad901abd49755d2a2a2f1f6c3e87d12b94"
  ],
  "author": {
    "name": "David Benjamin",
    "email": "davidben@google.com",
    "time": "Fri May 24 15:31:28 2024 -0400"
  },
  "committer": {
    "name": "Boringssl LUCI CQ",
    "email": "boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "time": "Fri May 24 21:44:57 2024 +0000"
  },
  "message": "Fix some enum issues in the test-only BORINGSSL_FIPS_COUNTERS build\n\nThis fixes b/342634459.\n\nenums are weird. They\u0027re neither tight sum types, nor ints with\ndesignated values but something in between.\n\nBy default (i.e. if you do not say `enum Foo : int`, which isn\u0027t in C\nuntil very new versions), an enum\u0027s range of valid values is the\nsmallest hypothetical-bit-width signed or unsigned integer that can fit\nall the values. So, the following enum can only hold 0, 1, 2, or 3, and\nall values outside that range are UB.\n\n  enum E {\n    A \u003d 0,\n    B \u003d 2,\n  }\n\nMeanwhile, enum is signed and can hold values -2, -1, 0, 1:\n\n  enum E {\n    A \u003d -1,\n    B \u003d 1,\n  }\n\nThis is incredibly bizarre. This has two consequences. First, clang\nemits a warning like the following:\n\n.../boringssl/crypto/fipsmodule/self_check/fips.c:75:15: error: result of comparison of unsigned enum expression \u003c 0 is always false [-Werror,-Wtautological-unsigned-enum-zero\n-compare]\n   75 |   if (counter \u003c 0 || counter \u003e fips_counter_max) {\n      |       ~~~~~~~ ^ ~\n\nSecond, this loop over enum values in the unit test trips UBSan.\n\n[----------] 1 test from CryptoTest\n[ RUN      ] CryptoTest.FIPSCountersEVP_AEAD\n.../boringssl/crypto/crypto_test.cc:51:8: runtime error: load of value 4, which is not a valid value for type \u0027fips_counter_t\u0027\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/google/home/davidben/boringssl/crypto/crypto_test.cc:51:8\n\nTo avoid this, just do our arithemetic in integer space and only move to\nenums at the edges.\n\nChange-Id: Icbd0e41604ce2aa67be8d394b03c7de50062199c\nReviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68768\nCommit-Queue: David Benjamin \u003cdavidben@google.com\u003e\nAuto-Submit: David Benjamin \u003cdavidben@google.com\u003e\nReviewed-by: Bob Beck \u003cbbe@google.com\u003e\nReviewed-by: Adam Langley \u003cagl@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4543d5c10650822b36302a6ae8a2c905cfafbe1c",
      "old_mode": 33188,
      "old_path": "crypto/crypto_test.cc",
      "new_id": "7be370b20fa411d3ea51f14738463653b104ea50",
      "new_mode": 33188,
      "new_path": "crypto/crypto_test.cc"
    },
    {
      "type": "modify",
      "old_id": "c3515ea9e38ce3e8b3fdd5b83192edf3039617b8",
      "old_mode": 33188,
      "old_path": "crypto/fipsmodule/self_check/fips.c",
      "new_id": "ca6fb3ac3e758ba67f23221eb240eb2db60ec531",
      "new_mode": 33188,
      "new_path": "crypto/fipsmodule/self_check/fips.c"
    }
  ]
}
