diff options
-rw-r--r-- | usr/src/cmd/ndmpadm/ndmpadm_main.c | 8 | ||||
-rw-r--r-- | usr/src/lib/libndmp/common/libndmp.h | 9 | ||||
-rw-r--r-- | usr/src/lib/libndmp/common/libndmp_base64.c | 18 | ||||
-rw-r--r-- | usr/src/lib/libndmp/common/libndmp_prop.c | 30 |
4 files changed, 35 insertions, 30 deletions
diff --git a/usr/src/cmd/ndmpadm/ndmpadm_main.c b/usr/src/cmd/ndmpadm/ndmpadm_main.c index ad06c2b4a0..4948283cb6 100644 --- a/usr/src/cmd/ndmpadm/ndmpadm_main.c +++ b/usr/src/cmd/ndmpadm/ndmpadm_main.c @@ -616,14 +616,14 @@ ndmp_enable_auth(int argc, char **argv, ndmp_command_t *cur_cmd) if (strncmp(auth_type, ndmp_auth_table[i].auth_type, strlen(ndmp_auth_table[i].auth_type)) == 0) { auth_type_flag = 1; - if ((ndmp_set_prop((char *)ndmp_auth_table[i].username, + if ((ndmp_set_prop(ndmp_auth_table[i].username, username)) == -1) { (void) fprintf(stdout, gettext("Could not set username - %s\n"), ndmp_strerror(ndmp_errno)); continue; } - if ((ndmp_set_prop((char *)ndmp_auth_table[i].password, + if ((ndmp_set_prop(ndmp_auth_table[i].password, enc_password)) == -1) { (void) fprintf(stdout, gettext("Could not set password - %s\n"), @@ -677,14 +677,14 @@ ndmp_disable_auth(int argc, char **argv, ndmp_command_t *cur_cmd) if (strncmp(auth_type, ndmp_auth_table[i].auth_type, strlen(ndmp_auth_table[i].auth_type)) == 0) { auth_type_flag = 1; - if ((ndmp_set_prop((char *)ndmp_auth_table[i].username, + if ((ndmp_set_prop(ndmp_auth_table[i].username, "")) == -1) { (void) fprintf(stdout, gettext("Could not clear username - %s\n"), ndmp_strerror(ndmp_errno)); continue; } - if ((ndmp_set_prop((char *)ndmp_auth_table[i].password, + if ((ndmp_set_prop(ndmp_auth_table[i].password, "")) == -1) { (void) fprintf(stdout, gettext("Could not clear password - %s\n"), diff --git a/usr/src/lib/libndmp/common/libndmp.h b/usr/src/lib/libndmp/common/libndmp.h index 2a85462809..b4f064ace6 100644 --- a/usr/src/lib/libndmp/common/libndmp.h +++ b/usr/src/lib/libndmp/common/libndmp.h @@ -37,6 +37,7 @@ */ /* Copyright (c) 2007, The Storage Networking Industry Association. */ /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */ +/* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ #ifndef _LIBNDMP_H #define _LIBNDMP_H @@ -347,11 +348,11 @@ extern int ndmp_terminate_session(int); extern int ndmp_set_dbglevel(int); extern const char *ndmp_strerror(int); extern int ndmp_door_status(void); -extern int ndmp_get_prop(char *, char **); -extern int ndmp_set_prop(char *, char *); +extern int ndmp_get_prop(const char *, char **); +extern int ndmp_set_prop(const char *, const char *); extern int ndmp_service_refresh(void); -extern char *ndmp_base64_encode(char *); -extern char *ndmp_base64_decode(char *); +extern char *ndmp_base64_encode(const char *); +extern char *ndmp_base64_decode(const char *); extern ndmp_door_ctx_t *ndmp_door_decode_start(char *, int); extern int ndmp_door_decode_finish(ndmp_door_ctx_t *); extern ndmp_door_ctx_t *ndmp_door_encode_start(char *, int); diff --git a/usr/src/lib/libndmp/common/libndmp_base64.c b/usr/src/lib/libndmp/common/libndmp_base64.c index c3d537da49..0e0aad576d 100644 --- a/usr/src/lib/libndmp/common/libndmp_base64.c +++ b/usr/src/lib/libndmp/common/libndmp_base64.c @@ -36,6 +36,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +/* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ #include <stdio.h> #include <sys/types.h> @@ -47,9 +48,6 @@ #define NDMP_ENC_LEN 1024 #define NDMP_DEC_LEN 256 -char *ndmp_base64_encode(char *); -char *ndmp_base64_decode(char *); - static boolean_t ndmp_is_base64(unsigned char); static char *b64_data = @@ -61,9 +59,9 @@ ndmp_is_base64(unsigned char c) return (isalnum(c) || (c == '+') || (c == '/')); } -/* caller should use the encloded string and then free the string. */ +/* caller should use the encoded string and then free the string. */ char * -ndmp_base64_encode(char *str_to_encode) +ndmp_base64_encode(const char *str_to_encode) { int ret_cnt = 0; int i = 0, j = 0; @@ -115,7 +113,7 @@ ndmp_base64_encode(char *str_to_encode) } char * -ndmp_base64_decode(char *encoded_str) +ndmp_base64_decode(const char *encoded_str) { int len = strlen(encoded_str); int i = 0, j = 0; @@ -136,8 +134,10 @@ ndmp_base64_decode(char *encoded_str) en_ind++; if (i == 4) { for (i = 0; i < 4; i++) { - if ((p = strchr(b64_data, arr_4[i])) == NULL) + if ((p = strchr(b64_data, arr_4[i])) == NULL) { + free(ret); return (NULL); + } arr_4[i] = (int)(p - b64_data); } @@ -161,8 +161,10 @@ ndmp_base64_decode(char *encoded_str) arr_4[j] = 0; for (j = 0; j < 4; j++) { - if ((p = strchr(b64_data, arr_4[j])) == NULL) + if ((p = strchr(b64_data, arr_4[j])) == NULL) { + free(ret); return (NULL); + } arr_4[j] = (int)(p - b64_data); } diff --git a/usr/src/lib/libndmp/common/libndmp_prop.c b/usr/src/lib/libndmp/common/libndmp_prop.c index b0142d9a4c..f29aadb4a2 100644 --- a/usr/src/lib/libndmp/common/libndmp_prop.c +++ b/usr/src/lib/libndmp/common/libndmp_prop.c @@ -75,15 +75,17 @@ typedef struct ndmp_scfhandle { } ndmp_scfhandle_t; static int ndmp_config_saveenv(ndmp_scfhandle_t *); -static ndmp_scfhandle_t *ndmp_smf_scf_init(char *); +static ndmp_scfhandle_t *ndmp_smf_scf_init(const char *); static void ndmp_smf_scf_fini(ndmp_scfhandle_t *); static int ndmp_smf_start_transaction(ndmp_scfhandle_t *); static int ndmp_smf_end_transaction(ndmp_scfhandle_t *); -static int ndmp_smf_set_property(ndmp_scfhandle_t *, char *, char *); -static int ndmp_smf_get_property(ndmp_scfhandle_t *, char *, char *, size_t); -static int ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *, char *); -static int ndmp_smf_delete_property(ndmp_scfhandle_t *, char *); -static int ndmp_smf_get_pg_name(ndmp_scfhandle_t *, char *, char **); +static int ndmp_smf_set_property(ndmp_scfhandle_t *, const char *, + const char *); +static int ndmp_smf_get_property(ndmp_scfhandle_t *, const char *, char *, + size_t); +static int ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *, const char *); +static int ndmp_smf_delete_property(ndmp_scfhandle_t *, const char *); +static int ndmp_smf_get_pg_name(ndmp_scfhandle_t *, const char *, char **); /* * This routine send a refresh signal to ndmpd service which cause ndmpd @@ -105,7 +107,7 @@ ndmp_service_refresh(void) * defined otherwise it would be NULL. */ int -ndmp_get_prop(char *prop, char **value) +ndmp_get_prop(const char *prop, char **value) { ndmp_scfhandle_t *handle = NULL; char *lval = (char *)malloc(NDMP_PROP_LEN); @@ -141,7 +143,7 @@ ndmp_get_prop(char *prop, char **value) } int -ndmp_set_prop(char *env, char *env_val) +ndmp_set_prop(const char *env, const char *env_val) { ndmp_scfhandle_t *handle = NULL; char *pgname; @@ -176,7 +178,7 @@ ndmp_set_prop(char *env, char *env_val) } static int -ndmp_smf_get_pg_name(ndmp_scfhandle_t *h, char *pname, char **pgname) +ndmp_smf_get_pg_name(ndmp_scfhandle_t *h, const char *pname, char **pgname) { scf_value_t *value; scf_property_t *prop; @@ -250,7 +252,7 @@ ndmp_smf_scf_fini(ndmp_scfhandle_t *handle) * ndmp_scfhandle_t pointer if success. */ static ndmp_scfhandle_t * -ndmp_smf_scf_init(char *svc_name) +ndmp_smf_scf_init(const char *svc_name) { ndmp_scfhandle_t *handle; @@ -301,7 +303,7 @@ err: * Create a new property group at service level. */ static int -ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *handle, char *pgroup) +ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *handle, const char *pgroup) { int err; @@ -397,7 +399,7 @@ ndmp_smf_end_transaction(ndmp_scfhandle_t *handle) * Deletes property in current pg */ static int -ndmp_smf_delete_property(ndmp_scfhandle_t *handle, char *propname) +ndmp_smf_delete_property(ndmp_scfhandle_t *handle, const char *propname) { scf_transaction_entry_t *entry = NULL; @@ -430,7 +432,7 @@ ndmp_smf_delete_property(ndmp_scfhandle_t *handle, char *propname) */ static int ndmp_smf_set_property(ndmp_scfhandle_t *handle, - char *propname, char *valstr) + const char *propname, const char *valstr) { int ret = 0; scf_value_t *value = NULL; @@ -516,7 +518,7 @@ ndmp_smf_set_property(ndmp_scfhandle_t *handle, * memory allocated. */ static int -ndmp_smf_get_property(ndmp_scfhandle_t *handle, char *propname, +ndmp_smf_get_property(ndmp_scfhandle_t *handle, const char *propname, char *valstr, size_t sz) { int ret = 0; |