~firmware-testing-team/fwts/master

Viewing all changes in revision 4677.

  • Committer: Alex Hung
  • Author(s): Colin Ian King
  • Date: 2021-01-18 19:23:49 UTC
  • Revision ID: git-v1:1ddf98c5e06024cb5b37d8caa59f8d18b06084ef
uefi: add a helper to check for address overflow

Cppcheck found some code that indeed was being optimized out,
so add an inline helper function do to the overflow checking
in a way that actually works.

Fixes cppcheck warning:
src/uefi/securebootcert/securebootcert.c:274:49: warning: Invalid test
for overflow 'var_data_addr+siglist.SignatureListSize<var_data_addr';
pointer overflow is undefined behavior. Some mainstream compilers
remove such overflow tests when optimising the code and assume it's
always false. [invalidTestForOverflow]:

  if (var_data_addr + siglist.SignatureListSize < var_data_addr)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Alex Hung <alex.hung@canonical.com>
Acked-by: Ivan Hu <ivan.hu@canonical.com>

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: