Skip to content

Commit

Permalink
dtrust-tool: fix memory leak
Browse files Browse the repository at this point in the history
If `qespin1` and `qespin2` doesn't match, `qespin2` was neither cleared
nor freed;
  • Loading branch information
hamarituc committed Jun 3, 2024
1 parent 6ceb50e commit 58910ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tools/dtrust-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ unlock_transport_protection(sc_card_t *card)

if (strcmp(qespin1, qespin2)) {
fprintf(stderr, "New signature PINs doesn't match.\n");
goto fail_qespin2;
goto fail_qespincmp;
}
data.pin1.data = (u8 *)tpin;
data.pin1.len = strlen(tpin);
Expand All @@ -196,6 +196,7 @@ unlock_transport_protection(sc_card_t *card)
else
printf("Can't change pin: %s\n", sc_strerror(r));

fail_qespincmp:
if (qespin2 != NULL) {
sc_mem_clear(qespin2, qespin2_len);
free(qespin2);
Expand Down

0 comments on commit 58910ab

Please sign in to comment.