Skip to content

Commit a301e33

Browse files
authored
Merge pull request #344 from ionut-arm/dangling-pointer
Fix dangling pointer issue
2 parents 2ffedac + a75043b commit a301e33

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,13 @@ jobs:
6969
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora
7070
- name: Run the tests
7171
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/all-fedora.sh
72+
73+
tests-valgrind:
74+
name: Valgrind test run
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v2
78+
- name: Build the container
79+
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
80+
- name: Run the tests
81+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/valgrind.sh

tss-esapi/src/context/tpm_commands/session_commands.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl Context {
5959
auth_hash: HashingAlgorithm,
6060
) -> Result<Option<AuthSession>> {
6161
let mut session_handle = ObjectHandle::None.into();
62+
let potential_tpm2b_nonce = nonce.map(|v| v.into());
6263
let ret = unsafe {
6364
Esys_StartAuthSession(
6465
self.mut_context(),
@@ -70,7 +71,7 @@ impl Context {
7071
self.optional_session_1(),
7172
self.optional_session_2(),
7273
self.optional_session_3(),
73-
nonce.map_or_else(null, |v| &v.into()),
74+
potential_tpm2b_nonce.as_ref().map_or_else(null, |v| v),
7475
session_type.into(),
7576
&symmetric.try_into()?,
7677
auth_hash.into(),

tss-esapi/tests/valgrind.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 Contributors to the Parsec project.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Script for running valgrind against the set of tests
7+
# Intended for running in the Ubuntu container
8+
9+
set -euf -o pipefail
10+
11+
#################################
12+
# Run the TPM simulation server #
13+
#################################
14+
tpm_server &
15+
sleep 5
16+
tpm2_startup -c -T mssim
17+
18+
##########################
19+
# Install cargo-valgrind #
20+
##########################
21+
apt install -y valgrind
22+
cargo install cargo-valgrind
23+
24+
#################
25+
# Run the tests #
26+
#################
27+
TEST_TCTI=mssim: RUST_BACKTRACE=1 RUST_LOG=info cargo valgrind test -- --test-threads=1 --nocapture

0 commit comments

Comments
 (0)