Skip to content

Commit c525421

Browse files
Allocate the right amount of memory for auth_policy
For some reason we did a malloc(UINT16_MAX+...) which is way to much for a policy. Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 14b9445 commit c525421

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/tpm2_setprimarypolicy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static tool_rc process_inputs(ESYS_CONTEXT *ectx, tpm2_option_flags flags) {
106106
*/
107107
if (ctx.policy_path) {
108108

109-
ctx.auth_policy = malloc(UINT16_MAX + sizeof(uint16_t));
109+
ctx.auth_policy = malloc(sizeof(*ctx.auth_policy));
110110
if (!ctx.auth_policy) {
111111
LOG_ERR("oom");
112112
return tool_rc_general_error;

0 commit comments

Comments
 (0)