diff options
author | Greg Hudson <ghudson@mit.edu> | 2013-02-09 00:43:35 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2013-02-09 00:43:35 -0500 |
commit | 7905cd6a2eddbf264242bb2a85f811878b2da7ab (patch) | |
tree | 72b4028cbe0e399e1d293e2b718530913f0a2673 /src/lib/krb5/os/locate_kdc.c | |
parent | 92e2bac0f38f7f60a8fc74b5964357212c4289e1 (diff) | |
download | krb5-7905cd6a2eddbf264242bb2a85f811878b2da7ab.tar.gz krb5-7905cd6a2eddbf264242bb2a85f811878b2da7ab.tar.xz krb5-7905cd6a2eddbf264242bb2a85f811878b2da7ab.zip |
Add and use k5memdup, k5memdup0 helpers
Add k5-int.h static functions to duplicate byte ranges, optionally
with a trailing zero byte, and set an error code like k5alloc does.
Use them where they would shorten existing code.
Diffstat (limited to 'src/lib/krb5/os/locate_kdc.c')
-rw-r--r-- | src/lib/krb5/os/locate_kdc.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index ed8cc641e..5bf77761a 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -400,13 +400,11 @@ module_locate_server(krb5_context ctx, const krb5_data *realm, krb5int_free_plugin_dir_data(ptrs); return ENOMEM; } - realmz = malloc(realm->length + 1); + realmz = k5memdup0(realm->data, realm->length, &code); if (realmz == NULL) { krb5int_free_plugin_dir_data(ptrs); - return ENOMEM; + return code; } - memcpy(realmz, realm->data, realm->length); - realmz[realm->length] = '\0'; for (i = 0; ptrs[i]; i++) { void *blob; |