From 80001c8b7b00773a9eb59050aff3b0056080aaf2 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Sat, 1 Mar 2025 23:02:58 -0500 Subject: [PATCH] Use k5_path_join() in krb5int_open_plugin_dirs() Simplify and improve the portability of krb5int_open_plugin_dirs() using k5_path_join(). (There is no immediate practical benefit as this function is only used to find kdb5, authdata, and locate plugin modules.) [ghudson@mit.edu: further simplified code; edited commit message] --- src/util/support/plugins.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/util/support/plugins.c b/src/util/support/plugins.c index 678d052e7a..752f085190 100644 --- a/src/util/support/plugins.c +++ b/src/util/support/plugins.c @@ -403,12 +403,8 @@ krb5int_open_plugin_dirs (const char * const *dirnames, struct plugin_file_handle *handle = NULL; char *filepath = NULL; - if (!err) { - if (asprintf(&filepath, "%s/%s", dirnames[i], filenames[j]) < 0) { - filepath = NULL; - err = ENOMEM; - } - } + if (!err) + err = k5_path_join(dirnames[i], filenames[j], &filepath); if (!err && krb5int_open_plugin(filepath, &handle, ep) == 0) { err = krb5int_plugin_file_handle_array_add (&h, &count, handle); @@ -432,10 +428,7 @@ krb5int_open_plugin_dirs (const char * const *dirnames, strcmp(fnames[j], "..") == 0) continue; - if (asprintf(&filepath, "%s/%s", dirnames[i], fnames[j]) < 0) { - filepath = NULL; - err = ENOMEM; - } + err = k5_path_join(dirnames[i], fnames[j], &filepath); if (!err && krb5int_open_plugin(filepath, &handle, ep) == 0) { err = krb5int_plugin_file_handle_array_add(&h, &count, -- 2.47.2