Skip to content

Commit 47e1f77

Browse files
committed
Zero LMS key verify buffer
F/3309
1 parent 05f5f5c commit 47e1f77

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tools/lms/lms_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,25 @@ static int lms_write_key(const byte * priv, word32 privSz, void * context)
8282
if (n_read != n_write) {
8383
fprintf(stderr, "error: read %d, expected %d: %d\n",
8484
(int)n_read, (int)n_write, ferror(file));
85+
wc_ForceZero(buff, sizeof(buff));
8586
return WC_LMS_RC_WRITE_FAIL;
8687
}
8788

8889
n_cmp = XMEMCMP(buff, priv, n_write);
8990
if (n_cmp != 0) {
9091
fprintf(stderr, "error: write data was corrupted: %d\n", n_cmp);
92+
wc_ForceZero(buff, sizeof(buff));
9193
return WC_LMS_RC_WRITE_FAIL;
9294
}
9395

9496
err = fclose(file);
9597
if (err) {
9698
fprintf(stderr, "error: fclose returned %d\n", err);
99+
wc_ForceZero(buff, sizeof(buff));
97100
return WC_LMS_RC_WRITE_FAIL;
98101
}
99102

103+
wc_ForceZero(buff, sizeof(buff));
100104
return WC_LMS_RC_SAVED_TO_NV_MEMORY;
101105
}
102106

0 commit comments

Comments
 (0)