Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
3460: Fix for loop bugs in attesttls sample. r=yentsanglee a=qiucwang

PR#3453 introduced bugs in for loop in attesttls sample:
```
server\enc\identity_verifier.cpp:55:23: error: comparison of integers of different signs: 'int' and 'const size_t' (aka 'const unsigned long') [-Werror,-Wsign-compare]
    for (int i = 0; i < claim->value_size; i++)
```
This PR fixed those bugs.



Signed-off-by: Qiucheng Wang <[email protected]>

Co-authored-by: Qiucheng Wang <[email protected]>
  • Loading branch information
oeciteam and qiucwang committed Aug 31, 2020
2 parents b6aa388 + 4329d50 commit 750eeeb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions samples/attested_tls/client/enc/identity_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ oe_result_t enclave_claims_verifier_callback(
goto exit;
}
printf(TLS_CLIENT "\nverify unique_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
{
printf("0x%0x ", (uint8_t)claim->value[i]);
if (SERVER_ENCLAVE_MRENCLAVE[i] != (uint8_t)claim->value[i])
{
printf(
TLS_CLIENT "\nunique_id[%d] expected: 0x%0x found: 0x%0x ",
TLS_CLIENT "\nunique_id[%lu] expected: 0x%0x found: 0x%0x ",
i,
SERVER_ENCLAVE_MRENCLAVE[i],
(uint8_t)claim->value[i]);
Expand All @@ -87,7 +87,7 @@ oe_result_t enclave_claims_verifier_callback(
goto exit;
}
printf(TLS_CLIENT "\nverify signer_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);

if (!verify_signer_id(
Expand Down Expand Up @@ -117,7 +117,7 @@ oe_result_t enclave_claims_verifier_callback(
goto exit;
}
printf(TLS_CLIENT "\nproduct_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);
printf("\n\n");

Expand Down
2 changes: 1 addition & 1 deletion samples/attested_tls/common/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool verify_signer_id(
if (memcmp(signer, signer_id_buf, signer_id_buf_size) != 0)
{
printf("mrsigner is not equal!\n");
for (int i = 0; i < (int)signer_id_buf_size; i++)
for (size_t i = 0; i < signer_id_buf_size; i++)
{
printf(
"0x%x - 0x%x\n", (uint8_t)signer[i], (uint8_t)signer_id_buf[i]);
Expand Down
10 changes: 5 additions & 5 deletions samples/attested_tls/non_enc_client/verify_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool verify_signer_id(
if (memcmp(calculated_signer, expected_signer, expected_signer_size) != 0)
{
printf("signer_id is not equal\n");
for (int i = 0; i < expected_signer_size; i++)
for (size_t i = 0; i < expected_signer_size; i++)
{
printf(
"0x%x - 0x%x\n",
Expand Down Expand Up @@ -129,13 +129,13 @@ oe_result_t enclave_claims_verifier(
goto done;
}
printf(TLS_CLIENT "\nverify unique_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
{
printf("0x%0x ", (uint8_t)claim->value[i]);
if (SERVER_ENCLAVE_MRENCLAVE[i] != (uint8_t)claim->value[i])
{
printf(
TLS_CLIENT "unique_id[%d] expected: 0x%0x found: 0x%0x ",
TLS_CLIENT "unique_id[%lu] expected: 0x%0x found: 0x%0x ",
i,
SERVER_ENCLAVE_MRENCLAVE[i],
(uint8_t)claim->value[i]);
Expand All @@ -161,7 +161,7 @@ oe_result_t enclave_claims_verifier(
goto done;
}
printf(TLS_CLIENT "\nproduct_id :\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);
printf("\n");

Expand All @@ -181,7 +181,7 @@ oe_result_t enclave_claims_verifier(
goto done;
}
printf(TLS_CLIENT "\nverify signer_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);

// In this sample, only signer_id validation is shown
Expand Down
6 changes: 3 additions & 3 deletions samples/attested_tls/server/enc/identity_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ oe_result_t enclave_claims_verifier_callback(
goto exit;
}
printf(TLS_CLIENT "\nunique_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);
printf("\n");

Expand All @@ -72,7 +72,7 @@ oe_result_t enclave_claims_verifier_callback(
goto exit;
}
printf(TLS_SERVER "\nverify signer_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);

if (!verify_signer_id(
Expand Down Expand Up @@ -102,7 +102,7 @@ oe_result_t enclave_claims_verifier_callback(
goto exit;
}
printf(TLS_SERVER "\nproduct_id:\n");
for (int i = 0; i < claim->value_size; i++)
for (size_t i = 0; i < claim->value_size; i++)
printf("0x%0x ", (uint8_t)claim->value[i]);
printf("\n\n");

Expand Down

0 comments on commit 750eeeb

Please sign in to comment.