From saper@saper.info  Tue Apr 19 22:57:09 2011
Return-Path: <saper@saper.info>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C6FEE106564A;
	Tue, 19 Apr 2011 22:57:09 +0000 (UTC)
	(envelope-from saper@saper.info)
Received: from l.saper.info (l.saper.info [IPv6:2001:41d0:1:d467::1000])
	by mx1.freebsd.org (Postfix) with ESMTP id 07C5C8FC15;
	Tue, 19 Apr 2011 22:57:08 +0000 (UTC)
Received: from l.saper.info (uucp@localhost [127.0.0.1])
	by l.saper.info (8.14.4/8.14.4) with ESMTP id p3JMuT6g034835
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Tue, 19 Apr 2011 22:56:29 GMT
	(envelope-from saper@saper.info)
Received: (from uucp@localhost)
	by l.saper.info (8.14.4/8.14.4/Submit) with UUCP id p3JMuTmt034834;
	Tue, 19 Apr 2011 22:56:29 GMT
	(envelope-from saper@saper.info)
Received: from radziecki.saper.info (localhost [127.0.0.1])
	by radziecki.saper.info (8.14.4/8.14.4) with ESMTP id p3JMuOw1072027
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Tue, 19 Apr 2011 22:56:24 GMT
	(envelope-from saper@saper.info)
Received: (from saper@localhost)
	by radziecki.saper.info (8.14.4/8.14.4/Submit) id p3JMuNSH071992;
	Tue, 19 Apr 2011 22:56:23 GMT
	(envelope-from saper)
Message-Id: <201104192256.p3JMuNSH071992@radziecki.saper.info>
Date: Tue, 19 Apr 2011 22:56:23 GMT
From: Marcin Cieslak <saper@saper.info>
To: FreeBSD-gnats-submit@freebsd.org
Cc: thierry@freebsd.org
Subject: [PATCH] x11/rxvt-unicode: fix BadAtom in X_ChangeProperty when pasting from some clients
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         156509
>Category:       ports
>Synopsis:       [PATCH] x11/rxvt-unicode: fix BadAtom in X_ChangeProperty when pasting from some clients
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    thierry
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 19 23:00:21 UTC 2011
>Closed-Date:    Wed May 04 18:45:47 UTC 2011
>Last-Modified:  Wed May 04 18:45:47 UTC 2011
>Originator:     Marcin Cieslak
>Release:        FreeBSD 9.0-CURRENT amd64
>Organization:
http://saper.info
>Environment:
System: FreeBSD radziecki.saper.info 9.0-CURRENT FreeBSD 9.0-CURRENT #1 r219785M: Mon Mar 21 11:40:40 CET
>Description:

I have found a bug in rxvt derivatives:

https://sourceforge.net/tracker/?func=detail&aid=3289852&group_id=221&atid=100221

http://thread.gmane.org/gmane.comp.terminal-emulators.rxvt-unicode.general/958


Added file(s):
- files/patch-src::screen.C

Port maintainer (thierry@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99
>How-To-Repeat:

Try to paste some text from rxvt-unicode into example1 client from:

http://michael.toren.net/mirrors/doc/X-copy+paste.txt

you should get:

urxvt: An X Error occurred, trying to continue after report.
urxvt: X Error of failed request:  BadAtom (invalid Atom parameter)
urxvt: Major opcode of failed request:  18
urxvt: (which is X_ChangeProperty)
urxvt: Atom id in failed request:  0x0
urxvt: Serial number of failed request:  347

in a shell that is parent to rxvt-unicode (where
rxvt-unicode was started from).

>Fix:

--- rxvt-unicode-9.10_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/x11/rxvt-unicode.orig/files/patch-src::screen.C /usr/ports/x11/rxvt-unicode/files/patch-src::screen.C
--- /usr/ports/x11/rxvt-unicode.orig/files/patch-src::screen.C	1970-01-01 01:00:00.000000000 +0100
+++ /usr/ports/x11/rxvt-unicode/files/patch-src::screen.C	2011-04-19 23:58:32.000000000 +0200
@@ -0,0 +1,73 @@
+--- src/screen.C.orig	2011-04-19 23:53:53.000000000 +0200
++++ src/screen.C	2011-04-19 23:57:02.000000000 +0200
+@@ -3619,6 +3619,7 @@
+ rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW
+ {
+   XSelectionEvent ev;
++  Atom property;
+ 
+   ev.type = SelectionNotify;
+   ev.property = None;
+@@ -3628,6 +3629,16 @@
+   ev.target = rq.target;
+   ev.time = rq.time;
+ 
++  /* ICCCM: 2.2. Responsibilities of the Selection Owner   
++   * SelectionRequest:
++   * If the specified property is None , the requestor
++   * an obsolete client. Owners are encouraged
++   * to support these clients by using the specified
++   * target atom as the property name to be used for
++   * the reply.
++   */
++  property = (rq.property == 0) ? rq.target : rq.property;
++
+   if (rq.target == xa[XA_TARGETS])
+     {
+       Atom target_list[6];
+@@ -3642,10 +3653,10 @@
+       *target++ = xa[XA_UTF8_STRING];
+ #endif
+ 
+-      XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM,
++      XChangeProperty (dpy, rq.requestor, property, XA_ATOM,
+                        32, PropModeReplace,
+                        (unsigned char *)target_list, target - target_list);
+-      ev.property = rq.property;
++      ev.property = property;
+     }
+ #if TODO // TODO
+   else if (rq.target == xa[XA_MULTIPLE])
+@@ -3655,15 +3666,15 @@
+ #endif
+   else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == XA_PRIMARY && selection.text)
+     {
+-      XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
++      XChangeProperty (dpy, rq.requestor, property, rq.target,
+                        32, PropModeReplace, (unsigned char *)&selection_time, 1);
+-      ev.property = rq.property;
++      ev.property = property;
+     }
+   else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
+     {
+-      XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
++      XChangeProperty (dpy, rq.requestor, property, rq.target,
+                        32, PropModeReplace, (unsigned char *)&clipboard_time, 1);
+-      ev.property = rq.property;
++      ev.property = property;
+     }
+   else if (rq.target == XA_STRING
+            || rq.target == xa[XA_TEXT]
+@@ -3744,10 +3755,10 @@
+           ct.encoding = target;
+         }
+ 
+-      XChangeProperty (dpy, rq.requestor, rq.property,
++      XChangeProperty (dpy, rq.requestor, property,
+                        ct.encoding, 8, PropModeReplace,
+                        ct.value, (int)ct.nitems);
+-      ev.property = rq.property;
++      ev.property = property;
+ 
+       if (freect)
+         XFree (ct.value);
--- rxvt-unicode-9.10_1.patch ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->thierry 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Apr 19 23:00:31 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156509 

From: Marcin Cieslak <saper@saper.info>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/156509: [PATCH] x11/rxvt-unicode: fix BadAtom in
 X_ChangeProperty when pasting from some clients
Date: Fri, 22 Apr 2011 10:35:26 +0000

 Emanuele Giaquinta has commited the change upstream:
 
 http://cvs.schmorp.de/rxvt-unicode/src/screen.C?r1=1.380&r2=1.381
State-Changed-From-To: open->closed 
State-Changed-By: thierry 
State-Changed-When: mer 4 mai 2011 18:44:02 UTC 
State-Changed-Why:  

Your proposed patch has been accepted upstream, and is part of v. 9.11. 

Thanks for your report! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=156509 
>Unformatted:
