Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some issue discovered by Coverity in agressive mode #328

Merged
merged 6 commits into from
May 29, 2022

Conversation

stefanberger
Copy link
Owner

This PR resolves some TPM 2 code issue discovered by Coverity in agressive mode.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Update the description of the tpm_io_getlocality() callback function
that the TPM 2 code invokes to get the currently active locality.
It is expected that the called software is trusted and returns a valid
locality number at all times and thus also always return TPM_SUCCESS.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
…rity)

Only access the entrysize variable if it was read from the buffer. In case
of an error just head towards the exit. Previously, an error would also
have lead the function to do no more useful processing and exited it with
an error code bug Coverity complains that the entrysize variable would be
access while it wasn't initialized.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
…erity)

Exit the loop when the variable could not be filled with data from the
byte stream. This avoids accessing the variable 'element' in case it
wasn't initialized. The old could would have accessed the possibly
uninitialized variable but exited the loop immediately after.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2566

  • 5 of 6 (83.33%) changed or added relevant lines in 4 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 77.462%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/tpm2/BnMath.c 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
src/tpm12/tpm_ticks.c 3 91.97%
Totals Coverage Status
Change from base Build 2564: 0.005%
Covered Lines: 29217
Relevant Lines: 37718

💛 - Coveralls

@stefanberger stefanberger merged commit 6a919f1 into master May 29, 2022
@stefanberger stefanberger deleted the stefanberger/coverity_fixes branch May 29, 2022 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants