From 3e5309768931629da555d0ea1b236913f4cc3484 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 22 Sep 2013 08:26:47 +0200 Subject: s3:net rpc conf: reorganize the validity check and canonicalization of the input in "setparm" Signed-off-by: Michael Adam Reviewed-by: Andrew Bartlett --- source3/utils/net_rpc_conf.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_conf.c b/source3/utils/net_rpc_conf.c index 49c2eaf5f8..edf612088a 100644 --- a/source3/utils/net_rpc_conf.c +++ b/source3/utils/net_rpc_conf.c @@ -1822,39 +1822,45 @@ static NTSTATUS rpc_conf_setparm_internal(struct net_context *c, break; } - /* check if parameter is valid for writing */ - if (!lp_canonicalize_parameter_with_value(argv[1], argv[2], - &canon_valname, - &canon_valstr)) - { - if (canon_valname == NULL) { - d_fprintf(stderr, "invalid parameter '%s' given\n", - argv[1]); - } else { - d_fprintf(stderr, "invalid value '%s' given for " - "parameter '%s'\n", argv[1], argv[2]); - } + /* + * check if parameter is valid for writing + */ + + if (!lp_parameter_is_valid(argv[1])) { + d_fprintf(stderr, "Invalid parameter '%s' given.\n", argv[1]); werr = WERR_INVALID_PARAM; goto error; } - if (!smbconf_reg_parameter_is_valid(canon_valname)) { + if (!smbconf_reg_parameter_is_valid(argv[1])) { d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n", argv[1]); werr = WERR_INVALID_PARAM; goto error; } - if (!strequal(argv[0], "global") && - lp_parameter_is_global(argv[1])) - { + if (!strequal(argv[0], "global") && lp_parameter_is_global(argv[1])) { d_fprintf(stderr, "Global parameter '%s' not allowed in " - "service definition ('%s').\n", canon_valname, + "service definition ('%s').\n", argv[1], argv[0]); werr = WERR_INVALID_PARAM; goto error; } + if (!lp_canonicalize_parameter_with_value(argv[1], argv[2], + &canon_valname, + &canon_valstr)) + { + /* + * We already know the parameter name is valid. + * So the value must be invalid. + */ + d_fprintf(stderr, "invalid value '%s' given for " + "parameter '%s'\n", argv[1], argv[2]); + werr = WERR_INVALID_PARAM; + goto error; + } + /* set the parameter */ status = dcerpc_winreg_set_sz(frame, b, &share_hnd, argv[1], argv[2], &werr); -- cgit