From: Michael Adam Date: Fri, 29 Jun 2007 12:30:41 +0000 (+0000) Subject: r23656: Add initial checking of the validity of a paramter X-Git-Tag: samba-4.0.0alpha6~801^2~5508 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=20733036644c11a6b4fa7466f9a5b3aa1cae3916;p=thirdparty%2Fsamba.git r23656: Add initial checking of the validity of a paramter given to "net conf setparm". Add a utility function lp_parameter_valid() for this to loadparm.c. Michael (This used to be commit 639051e58d4da9fb1116c19f0790250640b6ac7a) --- diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index c43a0325605..58ea751fa58 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -2776,6 +2776,18 @@ BOOL lp_add_printer(const char *pszPrintername, int iDefaultService) return (True); } + +/*************************************************************************** + Check whether the given parameter name is valid. + Parametric options (names containing a colon) are considered valid. +***************************************************************************/ + +BOOL lp_parameter_valid(const char *pszParmName) +{ + return ((map_parameter(pszParmName) != -1) || + (strchr(pszParmName, ':') != NULL)); +} + /*************************************************************************** Map a parameter's string representation to something we can use. Returns False if the parameter string is not recognised, else TRUE. diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index 021ac0005d7..5af2d6ccc53 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -167,6 +167,20 @@ static WERROR reg_setvalue_internal(struct registry_key *key, else { d_fprintf(stderr, "Only value types DWORD and SZ are" "currently implemented for setting values.\n"); + werr = WERR_INVALID_PARAM; + goto done; + } + + if (!lp_parameter_valid(valname)) { + d_fprintf(stderr, "Invalid parameter '%s' given.\n", valname); + werr = WERR_INVALID_PARAM; + goto done; + } + + if (registry_smbconf_valname_forbidden(valname)) { + d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n", + valname); + werr = WERR_INVALID_PARAM; goto done; }