From: Ken Hornstein Date: Sun, 2 Mar 2025 04:02:58 +0000 (-0500) Subject: Use k5_path_join() in krb5int_open_plugin_dirs() X-Git-Tag: krb5-1.22-beta1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1412%2Fhead;p=thirdparty%2Fkrb5.git 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] --- 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,