Bug 248549

Summary: x11/libX11 1.6.10,1 X Input Method connection is broken
Product: Ports & Packages Reporter: Atsuo Ohki <ohki>
Component: Individual Port(s)Assignee: freebsd-x11 (Nobody) <x11>
Status: Closed FIXED    
Severity: Affects Some People CC: x11, zeising
Priority: --- Flags: zeising: maintainer-feedback+
zeising: merge-quarterly?
Version: Latest   
Hardware: Any   
OS: Any   
URL: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/117

Description Atsuo Ohki 2020-08-09 07:58:23 UTC
From libX11-1.6.10,
some X Input Method client can not connect to Input Method server.

I suspect changes of module/im/ximcp/imRmAttr.c caused the problem.
attached diff fixes the problem.

--- modules/im/ximcp/imRmAttr.c.orig    2020-08-09 16:29:11.043873000 +0900
+++ modules/im/ximcp/imRmAttr.c 2020-08-09 16:30:33.335757000 +0900
@@ -1407,8 +1407,8 @@
     *names_len = 0;
     while (total > min_len) {
        len = attr[2];
-       if (len >= (total - min_len)) {
-           return 0;
+       if (len > (total - min_len)) {
+           return 0;   /* XXX */
        }
        *names_len += (len + 1);
        len += (min_len + XIM_PAD(len + 2));
Comment 1 Jan Beich freebsd_committer freebsd_triage 2020-08-09 09:52:50 UTC
Did you try ports r544154? If so better report upstream to https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues (or submit the patch as merge request).
Comment 2 Niclas Zeising freebsd_committer freebsd_triage 2020-08-10 16:44:23 UTC
As jbeich already noted, have you tried the latest version of libX11 from FreeBSD ports r544154?  If that does not work, please provide at least a way to reproduce the issue, or better yet, report the issue upstream and add the link to the issue here.
Comment 3 Atsuo Ohki 2020-08-10 23:01:29 UTC
(In reply to Jan Beich from comment #1 & comment #2)

I tried as follow

X Input Method server:  kinput2 (I know this is very old)
X Input Method clinet:  firefox-79.0_1,1 (pkg version)
                        libreoffice-6.4.5 & ja-libreoffice-6.4.5

0) before libX11-1.6.10,1, above combination works as expected
                           (I can enter Japanese text).

1) after upgrading to libX11-1.6.10,1 via `pkg upgrade', 
   above combination does not work as expected (I can't enter Japanese text).

2) tried making libX11.so from ports/x11/libX11
   # $FreeBSD: head/x11/libX11/Makefile 544154 2020-08-04 09:33:56Z zeising $

   --> above combination does not work.

3) applying my patch to ports sources,

   --> above combination does work as before(0)
Comment 4 Niclas Zeising freebsd_committer freebsd_triage 2020-08-11 08:31:56 UTC
(In reply to Atsuo Ohki from comment #3)

Then please report the issue upstream, as it is almost certainly an upstream issue.  The code in quesetion was added in https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/0e6561efcfaa0ae7b5c74eac7e064b76d687544e , which is part of the recent security fixes.
Since there has been recent security issues in this code, I won't change it locally without a discussion with upstream about it, so that I don't open new security issues.

Please report the issue upstream, include an easy way to reproduce it.  I'm not super familiar with X Input Methods, so any guide on how to use them and how to reproduce this would be helpful.
Comment 5 Atsuo Ohki 2020-08-11 10:12:42 UTC
(In reply to Niclas Zeising from comment #4)

I reported https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues today.
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-08-17 10:51:37 UTC
A commit references this bug:

Author: zeising
Date: Mon Aug 17 10:51:02 UTC 2020
New revision: 545155
URL: https://svnweb.freebsd.org/changeset/ports/545155

Log:
  x11/libX11: Fix regression with inputh methods

  Add an upstream patch to fix regressions with input metods, where input
  method clients can't connect to the input method server. [1]
  While here, add a patch that removes register keywords and fixes compiles
  against libX11 headers with C++17.

  PR:		248549 [1]
  Reported by:	Atsuo Ohki
  MFH:		2020Q3

Changes:
  head/x11/libX11/Makefile
  head/x11/libX11/distinfo
Comment 7 Niclas Zeising freebsd_committer freebsd_triage 2020-08-17 10:52:51 UTC
I've added the patch as applied upstream to libX11, so it should work now.  Awaiting MFH to fix it in the quarterly branch as well.
Comment 8 Atsuo Ohki 2020-08-17 11:39:36 UTC
(In reply to Niclas Zeising from comment #7)

I compiled from

 https://svnweb.freebsd.org/changeset/ports/545155

and resulting libX11 works as expected.

thank you for your support.
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-08-17 17:02:37 UTC
A commit references this bug:

Author: zeising
Date: Mon Aug 17 17:01:51 UTC 2020
New revision: 545175
URL: https://svnweb.freebsd.org/changeset/ports/545175

Log:
  MFH: r543914 r544154 r544630 r545155

  With these changes libX11 in 2020Q3 branch should be mostly up to date with
  what's in the default ports tree branch.

  This is needed because the amount of patches fixing various issues started to
  pile up, and it was hard to merge the needed patches one by one.

  x11/libX11: Update to 1.6.10

  Update x11/libX11 to 1.6.10.
  Changelog:
  https://lists.x.org/archives/xorg-announce/2020-July/003052.html

  PR:		248409
  Submitted by:	VVD

  x11/libX11: Fix regression after security fixes

  Add an upstream patch that fixes regressions after the last round of
  security updates, and the update to 1.6.10.
  This regression causes issues with emacs, at least.

  Reported by:	Kevin Oberman

  x11/libX11: Update to 1.6.11

  Update x11/libX11 to 1.6.11.
  This is effectively a noop, since the only change between 1.6.10 and 1.6.11
  has already been included in the port.
  Bump the version anyway to keep things up to date.

  x11/libX11: Fix regression with inputh methods

  Add an upstream patch to fix regressions with input metods, where input
  method clients can't connect to the input method server. [1]
  While here, add a patch that removes register keywords and fixes compiles
  against libX11 headers with C++17.

  PR:		248549 [1]
  Reported by:	Atsuo Ohki

  Approved by:	ports-secteam (joenum)

Changes:
_U  branches/2020Q3/
  branches/2020Q3/x11/libX11/Makefile
  branches/2020Q3/x11/libX11/distinfo
Comment 10 Niclas Zeising freebsd_committer freebsd_triage 2020-08-17 17:09:40 UTC
Merged

Thank you for the report!