[Spice-devel] [PATCH spice-xpi 3] Validate port values
Marc-André Lureau
mlureau at redhat.com
Wed Apr 4 09:10:01 PDT 2012
----- Mensaje original -----
> Done.
>
> ---
> SpiceXPI/src/plugin/plugin.cpp | 37
> +++++++++++++++++++++++++++++++++++--
> 1 files changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/SpiceXPI/src/plugin/plugin.cpp
> b/SpiceXPI/src/plugin/plugin.cpp
> index de7afd0..2e013d7 100644
> --- a/SpiceXPI/src/plugin/plugin.cpp
> +++ b/SpiceXPI/src/plugin/plugin.cpp
> @@ -104,6 +104,22 @@ namespace {
>
> return dest;
> }
> +
> + // helper function for tcp/udp range conversion and validation
> + static int portToInt(const std::string &port)
> + {
> + if (port.empty())
> + return -1;
> +
> + char *end;
> + long int conv = strtol(port.c_str(), &end, 10);
> + if (*end != '\0')
> + return -2;
> + if (conv < 0 || conv > 65535)
> + return -2;
Can someone confirm that we never use -1 to indicate disabled port? I would rather change the checked range to accept -1, if it's a value we accepted until now for this purpose.
More information about the Spice-devel
mailing list