Bug 251275 - shells/ksh2020 "complete -F" doesn't work unless the prefix length is exactly 3
Summary: shells/ksh2020 "complete -F" doesn't work unless the prefix length is exactly 3
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Cy Schubert
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2020-11-20 16:10 UTC by Romeo Rajomalaza
Modified: 2020-12-03 04:23 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (cy)


Attachments
Don't reassign the "len" variable and compute the exact spaces needed (491 bytes, patch)
2020-11-20 16:10 UTC, Romeo Rajomalaza
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Romeo Rajomalaza 2020-11-20 16:10:56 UTC
Created attachment 219832 [details]
Don't reassign the "len" variable and compute the exact spaces needed

Hi,

The programmable completion of ksh2020 doesn't work as expected unless the prefix length is exactly 3.  The following example illustrates the problem:

$ set -o emacs
$ _foo()
> {
> COMPREPLY=( hello world )
> }
$ complete -F _foo foo
$ foo <tab> # Nothing is displayed.
$ foo hel<tab> # This one works as expected.

The problem is caused by a reassignment of the prefix length.  Moreover, we might overwrite data on the heap if the total length of all completion strings is big enough.  The attached patch fixes the problem.
Comment 1 commit-hook freebsd_committer 2020-12-02 18:44:22 UTC
A commit references this bug:

Author: cy
Date: Wed Dec  2 18:43:36 UTC 2020
New revision: 556844
URL: https://svnweb.freebsd.org/changeset/ports/556844

Log:
  Don't reassign the "len" variable and compute the exact spaces needed.

  PR:		251275
  Submitted by:	Romeo Rajomalaza <endian.sign _ gmail.com>
  Reported by:	Romeo Rajomalaza <endian.sign _ gmail.com>
  MFH:		2020Q4

Changes:
  head/shells/ksh2020/Makefile
  head/shells/ksh2020/files/patch-src_cmd_ksh93_edit_pcomplete.c
Comment 2 commit-hook freebsd_committer 2020-12-03 04:23:26 UTC
A commit references this bug:

Author: cy
Date: Thu Dec  3 04:22:52 UTC 2020
New revision: 556884
URL: https://svnweb.freebsd.org/changeset/ports/556884

Log:
  MFH: r556844

  Don't reassign the "len" variable and compute the exact spaces needed.

  PR:		251275
  Submitted by:	Romeo Rajomalaza <endian.sign _ gmail.com>
  Reported by:	Romeo Rajomalaza <endian.sign _ gmail.com>
  Approved by:	ports-secteam (fluffy)

Changes:
_U  branches/2020Q4/
  branches/2020Q4/shells/ksh2020/Makefile
  branches/2020Q4/shells/ksh2020/files/patch-src_cmd_ksh93_edit_pcomplete.c