Skip to content

Commit

Permalink
Merge 0438602 into 7d79ecd
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanberger committed Oct 5, 2022
2 parents 7d79ecd + 0438602 commit 787d1af
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/swtpm/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ key_from_pwdfile_fd(int fd, unsigned char *key, size_t *keylen,
logprintf(STDERR_FILENO,
"Unable to read passphrase: %s\n",
strerror(errno));
goto exit;
goto err_free_buffer;
}
/* EOF ? */
if ((size_t)len < filelen - offset) {
Expand All @@ -345,7 +345,7 @@ key_from_pwdfile_fd(int fd, unsigned char *key, size_t *keylen,
logprintf(STDERR_FILENO,
"Requested %zu bytes for key, only got %zu.\n",
*keylen, sizeof(hashbuf));
goto exit;
goto err_free_buffer;
}
SHA512(filebuffer, len, hashbuf);
memcpy(key, hashbuf, *keylen);
Expand All @@ -356,21 +356,21 @@ key_from_pwdfile_fd(int fd, unsigned char *key, size_t *keylen,
EVP_sha512(), *keylen, key) != 1) {
logprintf(STDERR_FILENO,
"PKCS5_PBKDF2_HMAC with SHA512 failed\n");
goto exit;
goto err_free_buffer;
}
break;
case KDF_IDENTIFIER_UNKNOWN:
logprintf(STDERR_FILENO,
"Unknown KDF\n");
goto exit;
goto err_free_buffer;
}

ret = 0;

exit:

err_free_buffer:
free(filebuffer);

exit:
return ret;
}

Expand Down

0 comments on commit 787d1af

Please sign in to comment.