diff options
author | marcel <marcel@FreeBSD.org> | 2011-02-13 19:34:48 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2011-02-13 19:34:48 +0000 |
commit | 31f3b74d2338d597c3d86e8b2a7ace56b59c2848 (patch) | |
tree | 424e97a8f92299d57301f39967f6428cf0901966 | |
parent | 88337282fe7700f1bf01a77892390a206c284c81 (diff) | |
download | FreeBSD-src-31f3b74d2338d597c3d86e8b2a7ace56b59c2848.zip FreeBSD-src-31f3b74d2338d597c3d86e8b2a7ace56b59c2848.tar.gz |
Use the preload_fetch_addr() and preload_fetch_size() convenience
functions to obtain the address and size of the preloaded key files.
Sponsored by: Juniper Networks.
-rw-r--r-- | sys/geom/eli/g_eli.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 8834b86..d1c31bd 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -981,8 +981,9 @@ g_eli_destroy_geom(struct gctl_req *req __unused, static int g_eli_keyfiles_load(struct hmac_ctx *ctx, const char *provider) { - u_char *keyfile, *data, *size; + u_char *keyfile, *data; char *file, name[64]; + size_t size; int i; for (i = 0; ; i++) { @@ -990,15 +991,14 @@ g_eli_keyfiles_load(struct hmac_ctx *ctx, const char *provider) keyfile = preload_search_by_type(name); if (keyfile == NULL) return (i); /* Return number of loaded keyfiles. */ - data = preload_search_info(keyfile, MODINFO_ADDR); + data = preload_fetch_addr(keyfile); if (data == NULL) { G_ELI_DEBUG(0, "Cannot find key file data for %s.", name); return (0); } - data = *(void **)data; - size = preload_search_info(keyfile, MODINFO_SIZE); - if (size == NULL) { + size = preload_fetch_size(keyfile); + if (size == 0) { G_ELI_DEBUG(0, "Cannot find key file size for %s.", name); return (0); @@ -1011,15 +1011,16 @@ g_eli_keyfiles_load(struct hmac_ctx *ctx, const char *provider) } G_ELI_DEBUG(1, "Loaded keyfile %s for %s (type: %s).", file, provider, name); - g_eli_crypto_hmac_update(ctx, data, *(size_t *)size); + g_eli_crypto_hmac_update(ctx, data, size); } } static void g_eli_keyfiles_clear(const char *provider) { - u_char *keyfile, *data, *size; + u_char *keyfile, *data; char name[64]; + size_t size; int i; for (i = 0; ; i++) { @@ -1027,12 +1028,10 @@ g_eli_keyfiles_clear(const char *provider) keyfile = preload_search_by_type(name); if (keyfile == NULL) return; - data = preload_search_info(keyfile, MODINFO_ADDR); - size = preload_search_info(keyfile, MODINFO_SIZE); - if (data == NULL || size == NULL) - continue; - data = *(void **)data; - bzero(data, *(size_t *)size); + data = preload_fetch_addr(keyfile); + size = preload_fetch_size(keyfile); + if (data != NULL && size != 0) + bzero(data, size); } } |