[Spice-devel] [PATCH spice 1/2] spicec-x11: Don't crash on apps sending bad atoms as TARGETS

Alon Levy alevy at redhat.com
Wed Mar 23 09:26:37 PDT 2011


On Wed, Mar 23, 2011 at 05:18:50PM +0100, Hans de Goede wrote:
> Some apps (bad xsel, bad!) send invalid Atoms in their TARGETS property,
> causing spicec to exit because of an XError. This patch makes spicec survive
> this scenario.

ACK series.

> 
> For more info on the xsel bug, see:
> https://bugzilla.redhat.com/show_bug.cgi?id=690214
> ---
>  client/x11/platform.cpp |   28 ++++++++++++++++------------
>  1 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
> index 48d5a52..9fff947 100644
> --- a/client/x11/platform.cpp
> +++ b/client/x11/platform.cpp
> @@ -180,6 +180,18 @@ public:
>  static DefaultClipboardListener default_clipboard_listener;
>  static Platform::ClipboardListener* clipboard_listener = &default_clipboard_listener;
>  
> +static void handle_x_errors_start(void)
> +{
> +    handle_x_error = True;
> +    x_error_code = 0;
> +}
> +
> +static int handle_x_errors_stop(void)
> +{
> +    handle_x_error = False;
> +    return x_error_code;
> +}
> +
>  static const char *atom_name(Atom atom)
>  {
>      const char *name;
> @@ -188,7 +200,11 @@ static const char *atom_name(Atom atom)
>          return "None";
>  
>      XLockDisplay(x_display);
> +    handle_x_errors_start();
>      name = XGetAtomName(x_display, atom);
> +    if (handle_x_errors_stop()) {
> +        name = "Bad Atom";
> +    }
>      XUnlockDisplay(x_display);
>  
>      return name;
> @@ -317,18 +333,6 @@ Display* XPlatform::get_display()
>      return x_display;
>  }
>  
> -static void handle_x_errors_start(void)
> -{
> -    handle_x_error = True;
> -    x_error_code = 0;
> -}
> -
> -static int handle_x_errors_stop(void)
> -{
> -    handle_x_error = False;
> -    return x_error_code;
> -}
> -
>  bool XPlatform::is_x_shm_avail()
>  {
>      return x_shm_avail;
> -- 
> 1.7.3.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list