lib: resolves potential reads of uninitialized data

This commit is contained in:
Dave Pate
2019-01-07 14:20:01 -08:00
committed by Klas Lindfors
parent 9a72ec1ba1
commit 2e72c8f85c
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -274,8 +274,9 @@ ykpiv_rc ykpiv_util_list_keys(ykpiv_state *state, uint8_t *key_count, ykpiv_key
for (i = 0; i < sizeof(SLOTS); i++) {
cbBuf = sizeof(buf);
res = _read_certificate(state, SLOTS[i], buf, &cbBuf);
if (YKPIV_OK == (res = _read_certificate(state, SLOTS[i], buf, &cbBuf))) {
if ((res == YKPIV_OK) && (cbBuf > 0)) {
// add current slot to result, grow result buffer if necessary
cbRealloc = (sizeof(ykpiv_key) + cbBuf - 1) > (cbData - offset) ? MAX((sizeof(ykpiv_key) + cbBuf - 1) - (cbData - offset), CB_PAGE) : 0;