[Spice-devel] [PATCH] validate tcp port values

Uri Lublin uril at redhat.com
Wed Jul 11 05:03:30 PDT 2012


On 07/11/2012 02:03 PM, Peter Hatina wrote:
> Hi,
>
> I had a request to validate TCP port values in spice-xpi, so
> does this make sense for you?
>
> More info at https://bugzilla.redhat.com/show_bug.cgi?id=805602
>
> ---
>   SpiceXPI/src/plugin/plugin.cpp |   27 +++++++++++++++++++++++++--
>   1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
> index b7f61ba..4aac37e 100644
> --- a/SpiceXPI/src/plugin/plugin.cpp
> +++ b/SpiceXPI/src/plugin/plugin.cpp
> @@ -581,6 +593,15 @@ void nsPluginInstance::SendStr(uint32_t id, std::string str)
>
>   void nsPluginInstance::Connect()
>   {
> +    const int port = portToInt(m_port);
> +    const int sport = portToInt(m_secure_port);
> +    if (port<= 0)
> +        g_warning("invalid port: '%s'", m_port.c_str());
> +    if (sport<= 0)
> +        g_warning("invalid secure port: '%s'", m_secure_port.c_str());
> +    if (port<= 0&&  sport<= 0)
> +        return;
> +

I think simply returning here is not good.
You should also send a "disconnected" (or spice client exited) 
notification to the caller.

Regards,
     Uri.


More information about the Spice-devel mailing list