diff --git a/.clang-tidy b/.clang-tidy index dc90198a1..0d8e9250b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,8 +9,6 @@ # [TODO] # -bugprone-narrowing-conversions # [TODO] -# -bugprone-not-null-terminated-result -# [TODO] # # -clang-analyzer-optin.performance.Padding # We prefer logical/semantic order over (potentially insignificant) @@ -28,7 +26,6 @@ Checks: "\ -bugprone-easily-swappable-parameters, \ -bugprone-implicit-widening-of-multiplication-result, \ -bugprone-narrowing-conversions, \ - -bugprone-not-null-terminated-result, \ \ clang-analyzer, \ -clang-analyzer-optin.performance.Padding, \ diff --git a/src/tss2-policy/tss2_policy.c b/src/tss2-policy/tss2_policy.c index 8c3034d6f..ca7773680 100644 --- a/src/tss2-policy/tss2_policy.c +++ b/src/tss2-policy/tss2_policy.c @@ -415,7 +415,8 @@ Tss2_PolicyGetDescription( policy_ctx->path); const char *description = policy_ctx->policy.description; - size_t len = strlen(description); + /* length including null termination */ + size_t len = strlen(description) + 1; /* NULL buffer let calller know size */ if (!buffer) { @@ -429,9 +430,9 @@ Tss2_PolicyGetDescription( return_if_error(TSS2_POLICY_RC_BUFFER_TOO_SMALL, "Specified buffer is too small"); } - /* all is well, copy it to user and let them know size */ + /* all is well, copy it to user (including null termination) and let them know size */ *size = len; - memcpy(buffer, description, len); + strcpy(buffer, description); LOG_TRACE("finished, returning: 0x0"); return TSS2_RC_SUCCESS;