Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15747

[PATCH] Fix a problem `rl_bind_key' cannot create shadow binding for `C-@'

Path csiph.com!tncsrv06.tnetconsulting.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Koichi Murase <myoga.murase@gmail.com>
Newsgroups gnu.bash.bug
Subject [PATCH] Fix a problem `rl_bind_key' cannot create shadow binding for `C-@'
Date Thu, 19 Dec 2019 00:43:38 +0800
Lines 151
Approved bug-bash@gnu.org
Message-ID <mailman.1091.1576687436.1979.bug-bash@gnu.org> (permalink)
References <CAFLRLk9R5wexNV53fx6-V3rQEwKExfJsoDanZ9JqGFatG9GnKg@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/mixed; boundary="0000000000002077580599fd26ad"
X-Trace usenet.stanford.edu 1576687437 23231 209.51.188.17 (18 Dec 2019 16:43:57 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=5czajDuu/k3onOhw1TsaAeJ/ISjA2kyctQ4OKLVPm2I=; b=CIBIDlXiHhRAf7YAXn6zP/hxrHp1DEIkxyOWCsIsqCA1i8YCD7fLb6UNBJtPa6+gC0 H6kvZnos1pNsc4xXwjbEmNou50wWthtrqm2J8asjVJUVLp0IBDuChFeje0/m/+yDVAQm BydqUVCllnDilnIii0FUNTPg5eEUkuTYd5KyBAobYmpHxEp+X1NJ8xVWUZr2D0hD+k2E zidNdpLCNZJU1RwSGSPhd1cbHfA646a++xLZhpuPTcNW91OWFUCZw/tEeRyrrZNrZLUr LVaPGZuch7PTaxntFXNZVZq9BnK3WkceaXcjEIyQg7oJyurOF8mK98wblSXrjU1mAGg2 FB6w==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5czajDuu/k3onOhw1TsaAeJ/ISjA2kyctQ4OKLVPm2I=; b=Ff7UjSn99ihAGgJCOuY7NGsx2KL1C6hI5GJs1T7w7N60xBabxCSOCTmWB1goOCrG7Z JDOCovxxK6GpfBjhXIb7B5iGyQojqUFknzRI05LXoDZXqzOT6nTDeNW7SCs3yjQTDbwB gu8MUxa0zMQv8lE3ogm61SJlWhMPfBGTiRH0lVYaTr6iCFp4+LbM3OLICKUMfxQlKRzl ZQxzKFjVUKsPv7rdEJxdKwkAAyqBYAcvmNGMZQnnW+hNjNNQcAEjRL3exA3Ihy3gF9Ds uzYdlRQDkc/25S874pvcsljGhh5TaqJnzjbmxd6rcRaUAa+hPM9yyPM4UOtnuFSzgAUZ 5laQ==
X-Gm-Message-State APjAAAXXwo+PX8YUeB351PV+53tWaDhiGYz4gJ+kdWeAxRNXl/etAoNU 7m1B8bjWBgdmJcIqt4YYim80Ofup8RkKTXFHV/dMWfU/VOkPWg==
X-Google-Smtp-Source APXvYqzBvurgRk1pvIiyqrif9ZJq0bYIzGXXsd46iW9c7uq2Pf/2mM5yN6h77ODL4xeoJOGrkZGbZ+clPpokABJ4K1g=
X-Received by 2002:a19:86d7:: with SMTP id i206mr2276124lfd.119.1576687428953; Wed, 18 Dec 2019 08:43:48 -0800 (PST)
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2a00:1450:4864:20::142
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAFLRLk9R5wexNV53fx6-V3rQEwKExfJsoDanZ9JqGFatG9GnKg@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15747

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

This is another report.

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux hp2019 5.2.13-200.fc30.x86_64 #1 SMP Fri Sep 6
14:30:40 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 11
Release Status: maint

Description:

  One of the public interface of readline, the function
  `rl_bind_key (key, function)' does not work with key = 0 (C-@) when
  there are already bindings of keyseqs starting from "\C-@".
  This is because when `rl_bind_key' calls `rl_generic_bind',
  it fails to construct an appropriate untranslated keyseq for "\C-@".

Repeat-By:

  The function `rl_bind_key' is not widely used by current Bash codes,
  but to see the problem caused by this bug, one can use an older form
  of bind 'C-SPC:...' to register a shadow binding.

  $ LANG=C ./bash-3a7c642e --norc
  $ bind '"\C-@\C-@":"hello"'
  $ bind 'C-SPC:backward-char'
  $ echo* #<-- <C-@> (* is the cursor position)

  In the above example, the expected result is `ech*o' with `*' being
  the cursor position after the timeout, but the cursor does not move.
  But with the following newer form, we can get the expected result:

  $ LANG=C ./bash-3a7c642e --norc
  $ bind '"\C-@\C-@":"hello"'
  $ bind '"\C-@":backward-char'

Fix:

  I attach a patch `0001-....patch'. In the patch, the key '\0' is
  treated specially similarly to the key '\\'.

  By the way I think there is a memory leak in the same
  function. Could you check the second attached patch
  `0002-....patch'? I think if the original binding is a macro the
  memory block should be released before the pointer is overwritten.
  Actually I'm not quite sure, but at least in a similar function
  `rl_generic_bind', the macro string is released.

  I think there is a memory leak also in the `rl_generic_bind'.  The
  shadow macro which is stored in `map[ANYOTHERKEY].function' is not
  released before the overwrite. See the third patch `0003-....patch'.

Thank you,
Koichi

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] Fix a problem `rl_bind_key' cannot create shadow binding for `C-@' Koichi Murase <myoga.murase@gmail.com> - 2019-12-19 00:43 +0800

csiph-web