krb5 commit: Use k5_path_join() in krb5int_open_plugin_dirs()

ghudson at mit.edu ghudson at mit.edu
Wed Mar 5 14:20:58 EST 2025


https://github.com/krb5/krb5/commit/80001c8b7b00773a9eb59050aff3b0056080aaf2
commit 80001c8b7b00773a9eb59050aff3b0056080aaf2
Author: Ken Hornstein <kenh at cmf.nrl.navy.mil>
Date:   Sat Mar 1 23:02:58 2025 -0500

    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 at 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 678d052e7..752f08519 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,


More information about the cvs-krb5 mailing list