diff options
author | Zoltan Fridrich <zfridric@redhat.com> | 2022-11-09 16:10:58 +0100 |
---|---|---|
committer | Zoltan Fridrich <zfridric@redhat.com> | 2022-11-15 15:16:07 +0100 |
commit | 6a6119bb180450d156dfdb9c2b560744dcd464b2 (patch) | |
tree | 895cba4fce13647b1e7a8d0030be03c30831fad4 /lib | |
parent | 1d9e2af61fab8ca54deac832b080e9bdd363c351 (diff) | |
download | gnutls-6a6119bb180450d156dfdb9c2b560744dcd464b2.tar.gz |
Fipshmac: always use realpaths
Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fipshmac.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/fipshmac.c b/lib/fipshmac.c index b091572bdf..13051dfdab 100644 --- a/lib/fipshmac.c +++ b/lib/fipshmac.c @@ -102,20 +102,30 @@ static int get_hmac(const char *path, char *hmac, size_t hmac_size) static int print_lib_path(const char *path) { int ret; + char *real_path = NULL; char hmac[HMAC_STR_SIZE]; - ret = get_hmac(path, hmac, sizeof(hmac)); + real_path = canonicalize_file_name(path); + if (real_path == NULL) { + fprintf(stderr, "Could not get realpath from %s\n", path); + ret = GNUTLS_E_FILE_ERROR; + goto cleanup; + } + + ret = get_hmac(real_path, hmac, sizeof(hmac)); if (ret < 0) { fprintf(stderr, "Could not calculate HMAC for %s: %s\n", - last_component(path), gnutls_strerror(ret)); - return ret; + last_component(real_path), gnutls_strerror(ret)); + goto cleanup; } printf("[%s]\n", last_component(path)); - printf("path = %s\n", path); + printf("path = %s\n", real_path); printf("hmac = %s\n", hmac); - return 0; +cleanup: + free(real_path); + return ret; } static int print_lib_dl(const char *lib, const char *sym) |