From: Swen Schillig Date: Mon, 28 Jan 2019 13:35:30 +0000 (+0100) Subject: rpcclient: Use wrapper for string to integer conversion X-Git-Tag: talloc-2.2.0~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=414bc3748b6fbd54cbd50a0ff1f20cbe31b06ccc;p=thirdparty%2Fsamba.git rpcclient: Use wrapper for string to integer conversion In order to detect an value overflow error during the string to integer conversion with strtoul/strtoull, the errno variable must be set to zero before the execution and checked after the conversion is performed. This is achieved by using the wrapper function strtoul_err and strtoull_err. Signed-off-by: Swen Schillig Reviewed-by: Ralph Böhme Reviewed-by: Jeremy Allison --- diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 7e396f92a48..898ae6ad6fc 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1406,13 +1406,18 @@ static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli, uint32_t alias_rid; uint32_t access_mask = MAXIMUM_ALLOWED_ACCESS; struct dcerpc_binding_handle *b = cli->binding_handle; + int error = 0; if (argc != 3) { printf("Usage: %s builtin|domain [rid|name]\n", argv[0]); return NT_STATUS_OK; } - alias_rid = strtoul(argv[2], NULL, 10); + alias_rid = strtoul_err(argv[2], NULL, 10, &error); + if (error != 0) { + return NT_STATUS_INVALID_PARAMETER; + } + /* Open SAMR handle */ diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 0a850ddc6aa..f6d631761b2 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -2642,6 +2642,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, union spoolss_PrinterData data; DATA_BLOB blob; struct dcerpc_binding_handle *b = cli->binding_handle; + int error = 0; /* parse the command arguments */ if (argc < 5) { @@ -2707,7 +2708,12 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, W_ERROR_HAVE_NO_MEMORY(data.string); break; case REG_DWORD: - data.value = strtoul(argv[4], NULL, 10); + data.value = strtoul_err(argv[4], NULL, 10, &error); + if (error != 0) { + result = WERR_INVALID_PARAMETER; + goto done; + } + break; case REG_BINARY: data.binary = strhex_to_data_blob(mem_ctx, argv[4]);