Skip to content

Commit f2c17d9

Browse files
committed
More peer review fixes
1 parent b7253ef commit f2c17d9

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

.github/workflows/sanitizer.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
working-directory: ./wolfssl
2727
run: |
2828
./autogen.sh
29-
./configure --enable-wolftpm --enable-pkcallbacks
29+
./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
30+
CFLAGS="-DWC_RSA_NO_PADDING"
3031
make -j$(nproc)
3132
sudo make install
3233
sudo ldconfig

src/fwtpm/fwtpm_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8043,7 +8043,7 @@ static TPM_RC FwCmd_PolicyAuthorize(FWTPM_CTX* ctx, TPM2_Packet* cmd,
80438043
int match = 0;
80448044
FWTPM_DECLARE_VAR(hashCtx, wc_HashAlg);
80458045
int hashInit = 0;
8046-
enum wc_HashType wcHash;
8046+
enum wc_HashType wcHash = WC_HASH_TYPE_NONE;
80478047
byte ccBuf[4];
80488048
UINT32 cc = TPM_CC_PolicyAuthorize;
80498049
(void)cmdSize;

src/fwtpm/fwtpm_nv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int FwNvUnmarshalNvIndex(const byte* buf, word32* pos, word32 maxSz,
451451
{
452452
int rc;
453453
UINT16 dataLen;
454-
UINT8 written;
454+
UINT8 written = 0;
455455

456456
XMEMSET(nv, 0, sizeof(FWTPM_NvIndex));
457457
nv->inUse = 1;

src/fwtpm/fwtpm_tis.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ static void TisHandleRegAccess(FWTPM_CTX* ctx, FWTPM_TIS_REGS* regs)
194194
FWTPM_STS_DATA_EXPECT,
195195
FWTPM_TIS_BURST_COUNT);
196196

197-
/* If we have the TPM header (6 bytes), check if command
198-
* is complete based on the size field in bytes [2..5] */
197+
/* If we have the full TPM header (TPM2_HEADER_SIZE bytes),
198+
* check if command is complete based on the size field
199+
* in bytes [2..5] */
199200
if (regs->cmd_len >= TPM2_HEADER_SIZE) {
200201
UINT32 cmdTotalSz = FwLoadU32BE(regs->cmd_buf + 2);
201202
if (cmdTotalSz < TPM2_HEADER_SIZE ||

src/fwtpm/fwtpm_tis_shm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ static int TisShmInit(void* ctx, FWTPM_TIS_REGS** regs)
6868
{
6969
FWTPM_TIS_SHM_CTX* shm = (FWTPM_TIS_SHM_CTX*)ctx;
7070
int fd;
71+
int openFlags = O_CREAT | O_RDWR | O_TRUNC | O_NOFOLLOW;
72+
73+
#ifdef O_CLOEXEC
74+
openFlags |= O_CLOEXEC;
75+
#endif
7176

7277
/* Create shared memory file */
73-
fd = open(FWTPM_TIS_SHM_PATH, O_CREAT | O_RDWR | O_TRUNC | O_NOFOLLOW, 0600);
78+
fd = open(FWTPM_TIS_SHM_PATH, openFlags, 0600);
7479
if (fd < 0) {
7580
fprintf(stderr, "fwTPM TIS: open(%s) failed: %d (%s)\n",
7681
FWTPM_TIS_SHM_PATH, errno, strerror(errno));

src/tpm2_swtpm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static TPM_RC SwTpmTransmit(TPM2_CTX* ctx, const void* buffer, ssize_t bufSz)
9696
TPM_RC rc = TPM_RC_SUCCESS;
9797
ssize_t wrc = 0;
9898
const char* ptr;
99-
int remaining;
99+
ssize_t remaining;
100100

101101
if (ctx == NULL || ctx->tcpCtx.fd < 0 || buffer == NULL || bufSz <= 0) {
102102
return BAD_FUNC_ARG;
@@ -114,7 +114,7 @@ static TPM_RC SwTpmTransmit(TPM2_CTX* ctx, const void* buffer, ssize_t bufSz)
114114
rc = TPM_RC_FAILURE;
115115
break;
116116
}
117-
remaining -= (int)wrc;
117+
remaining -= wrc;
118118
ptr += wrc;
119119
}
120120

src/tpm2_util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <wolftpm/tpm2_types.h>
3232
#include <wolftpm/tpm2.h>
33+
#include <stdio.h>
3334

3435
#ifndef WOLFTPM2_NO_WOLFCRYPT
3536
#include <wolfssl/wolfcrypt/hash.h>

0 commit comments

Comments
 (0)