]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Use k5_path_join() in krb5int_open_plugin_dirs() 1412/head
authorKen Hornstein <kenh@cmf.nrl.navy.mil>
Sun, 2 Mar 2025 04:02:58 +0000 (23:02 -0500)
committerGreg Hudson <ghudson@mit.edu>
Wed, 5 Mar 2025 19:04:52 +0000 (14:04 -0500)
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

index 678d052e7a80d0806b041c28913f8accc7902be3..752f0851908b07c25dc24674a7676b05d99b9d24 100644 (file)
@@ -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,