[PATCH] D67287: [Diagnostics] Add -Wsizeof-array-div

Dmitri Gribenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 02:23:21 PDT 2019


gribozavr added a comment.

FWIW, we did find a false positive with this warning.

https://github.com/bluerise/openbsd/blob/664a06af7e423ff06d46383c669d33c7bea7d234/lib/libutil/bcrypt_pbkdf.c#L81

  uint32_t cdata[BCRYPT_WORDS];
  ...
  blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t));

Looks like a bug indeed, until we look at the documentation for `blf_enc`, https://man.openbsd.org/blowfish, which says that the function indeed accepts 64-bit-sized blocks. However, for unclear reasons, it accepts the buffer as `u_int32_t*`. So the callers must have a buffer of `u_int32_t`, but compute its size in `uint64_t`s.

So, is it a false positive? Yes. However, the code is indeed questionable.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67287/new/

https://reviews.llvm.org/D67287





More information about the llvm-commits mailing list