Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swtpm: Add another exit label to avoid gcc -fanalyzer false positive #762

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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