From 62e994ce9603e863ae6d9a2bbbe8aa35680d2e7c Mon Sep 17 00:00:00 2001 From: haad Date: Fri, 5 Jun 2009 19:56:40 +0000 Subject: Parse dm param string in libdevmapper and not in a dm target init function. Create proplib param dictionary entry in libdevmapper and pass it to dm in dm_ioctl dict. Param target is then passed to target init function, where is parse. I like this aproach much better than passing char **argv and trusting to user input. I have bumped minor lib/driver version. XXX. Add more sanity checks in kernel. --- sys/dev/dm/dm_ioctl.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'sys/dev/dm/dm_ioctl.c') diff --git a/sys/dev/dm/dm_ioctl.c b/sys/dev/dm/dm_ioctl.c index 9dc84fe6fc3..03f1a91f6bd 100644 --- a/sys/dev/dm/dm_ioctl.c +++ b/sys/dev/dm/dm_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.11 2009/04/13 18:51:54 haad Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.12 2009/06/05 19:56:40 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -680,21 +680,18 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) prop_object_iterator_t iter; prop_array_t cmd_array; - prop_dictionary_t target_dict; + prop_dictionary_t target_dict, param_dict; const char *name, *uuid, *type; uint32_t flags, ret, minor; - char *str; - ret = 0; flags = 0; name = NULL; uuid = NULL; dmv = NULL; last_table = NULL; - str = NULL; /* char *xml; xml = prop_dictionary_externalize(dm_dict); @@ -769,8 +766,7 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) * null and therefore it should be checked before we try to * use it. */ - prop_dictionary_get_cstring(target_dict, - DM_TABLE_PARAMS, (char**)&str); + param_dict = prop_dictionary_get(target_dict, DM_TABLE_PARAMS); if (SLIST_EMPTY(tbl)) /* insert this table to head */ @@ -783,19 +779,16 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) * therfore I have to pass it to target init * routine and parse parameters there. */ - if ((ret = target->init(dmv, &table_en->target_config, - str)) != 0) { + param_dict)) != 0) { dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE); dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE); - free(str, M_TEMP); - + dm_dev_unbusy(dmv); return ret; } last_table = table_en; - free(str, M_TEMP); } prop_object_iterator_release(iter); -- cgit