mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-02-04 21:19:14 +00:00
swtpm: Handle case where unknown blobtype is given (Coverity)
Handle the case where an unknown blobtype is given and therefore cannot be translated to a filename and blobname is NULL. Previously this would have lead to an error when trying to read the file, now we handle the failure case earlier. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
bfa79e91f2
commit
760ec8ea96
@ -131,7 +131,7 @@ int ctrlchannel_set_client_fd(struct ctrlchannel *cc, int fd)
|
||||
static int ctrlchannel_return_state(ptm_getstate *pgs, int fd)
|
||||
{
|
||||
uint32_t blobtype = be32toh(pgs->u.req.type);
|
||||
const char *blobname = tpmlib_get_blobname(blobtype);
|
||||
const char *blobname;
|
||||
uint32_t tpm_number = 0;
|
||||
unsigned char *blob = NULL;
|
||||
uint32_t blob_length = 0, return_length;
|
||||
@ -145,7 +145,11 @@ static int ctrlchannel_return_state(ptm_getstate *pgs, int fd)
|
||||
struct iovec iov[2];
|
||||
int iovcnt, n;
|
||||
|
||||
if (blobtype == PTM_BLOB_TYPE_VOLATILE)
|
||||
blobname = tpmlib_get_blobname(blobtype);
|
||||
if (!blobname)
|
||||
res = TPM_FAIL;
|
||||
|
||||
if (res == 0 && blobtype == PTM_BLOB_TYPE_VOLATILE)
|
||||
res = SWTPM_NVRAM_Store_Volatile();
|
||||
|
||||
if (res == 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user