Commit Graph

2704 Commits

Author SHA1 Message Date
tg c9ccf0bab7 MFC remaining fixes; tested locally a lot, plus remotely with
GNU C11 (Debian 20150413-1) version 5.0.1 20150413 (prerelease) [gcc-5-branch revision 222050] (x86_64-linux-gnu)
including ASan (testsuite) and Valgrind (short)
2015-04-19 19:18:07 +00:00
tg 65f9b93926 ordinarily, lineno must be mksh_uari_t, but edit.c most of all isn’t ready,
so we mitigate a bit (in var.c mostly) and tweak another type already, and
add some checks (mksh_{,u}ari_t must fit into {,unsigned }long) and print
line numbers with %lu already
2015-04-19 18:50:38 +00:00
tg a2a4e41975 make var.c:getint() more like misc.c:getn(), except for the API differences:
getn() parses a decimal 32-bit integer, getint() a POSIX- or ksh-style based
integer with unsigned wraparound to 32 bit, then possible negation (so that,
for example, -0xFFFFFFFF continues to work)
2015-04-19 18:13:31 +00:00
tg 94acf49453 a bit review-inspired getn/bi_getn review 2015-04-19 14:40:23 +00:00
tg b7332de28c a bit oksh-inspired getn return value checking, plus some code optimisation 2015-04-19 14:40:09 +00:00
tg a1ba509bb9 oksh RCSID sync: we use mksh getn() instead of OS strtonum() which is just as safe (audited right now) 2015-04-19 14:23:26 +00:00
tg b19747e3de irrelevant oksh RCSID sync: we already use getint, and our $COLUMNS differs a bit anyway 2015-04-19 14:22:09 +00:00
tg 4bea0cc227 MFC most things (see mksh.hts) to R50-stable; sync clog 2015-04-12 22:32:12 +00:00
tg cad9bc86d3 Implement the “FKSH functions have local scope for shell options” feature
for mksh but not lksh; bump to R51-alpha.

While here, tweak build scripts a bit, fixup MirBSD-specific Makefile
things, remove part of a comment that’s uninteresting.
2015-04-11 23:28:21 +00:00
tg 3251f18c12 document code to make mksh set ±U match the user locale from the environment
cf. http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/1246729/focus=606
2015-04-11 22:35:10 +00:00
tg 6b00977053 just another oksh rcsid-only sync (we bind to the Delete key since forever) 2015-04-11 22:09:49 +00:00
tg e1cda74d04 SECURITY: fix integer overflows related to file descriptor parsing
bug initially found by Pawel Wylecial (LP#1440685)
additional bug found and suggested fix by enh (elliott hughes)

This commit also renames struct ioword.flag to ioflag to disambiguate
it from other members named “flag”, changes it to an unsigned type,
and packs ioflag and unit into shorts each, to make the struct smaller
(aligned even: 16 bytes on 32-bit systems) and reviews some of the
code involved in fd handling, though there wasn’t much to be found.
2015-04-11 22:03:32 +00:00
tg 3c5c5d02fd fix IFS='\' issues, found by edualbus (Eduardo A. Bustamante López <dualbus@gmail.com>) 2015-04-11 21:18:47 +00:00
tg 4ee3269564 • the \: "${foo:=bar}${bar:=baz}" construct needs no spaces
• more set -u police
• 80c and tweaks while here
2015-04-11 19:01:59 +00:00
tg 451aef7a8a some robustness improvements for dot.mkshrc:
• do not use \return for return before we know we are mksh
  (plus fix a wrong-word mistake)
• quote the argument(s) to \: (“colon”) for SECURITY
• default $MKSH to /bin/mksh (not normally reached)
• while here: check $USER only once, not for each PS1 (speed)

this addresses and mostly closes LP#1441853 – prt.mkshrc (in
OBS home:mirabile/mksh and DEB wtf-mksh they are identical)
is already good; Android mkshrc needs only some small robustness
fixes (mostly colon-related; enh says TMPDIR is good); I tested
this with “mksh -eu” and “mksh -eul” on Debian and ecce and with
read-only “/” and nothing else mounted on ecce, and it WFM
2015-04-11 18:08:56 +00:00
tg 0620a5d034 sync clog 2015-03-21 00:12:46 +00:00
tg 07898d8a45 only lksh now implies unalias for a POSIX function definition (used e.g. in Debian sysvinit scripts that use a “stop” function) 2015-03-20 23:37:55 +00:00
tg 8641829e21 fix comment no longer true since commit 1004DC49710562ACCB2 2015-03-20 23:37:39 +00:00
tg 0947d274f6 use a perl test for fd-cloexec to avoid testing the tester with the tester; improve fd-cloexec description 2015-03-20 23:37:29 +00:00
tg 1351c5eb0f permit building lksh with printf builtin, for testing 2015-03-20 23:37:17 +00:00
tg 2097d45f7f oksh rcsid-only sync, plus bonus rewrite of strip_nuls
(uses size_t ipv int for buffer size now, and no extra
calls to memchr/memmove, input is typically small)
2015-03-20 21:46:41 +00:00
tg 8967f13bc6 oksh rcsid-only sync, plus a fix in the commit whose body I skipped
sync’ing, plus a bonus fix inspired by their commits in sh.1…
2015-03-20 21:23:52 +00:00
tg 5c5fb404b1 fix “read -n-1”, which still returns once the first read() succeeds
(it’s not identical to “read -N-1”!)
2015-03-20 21:01:41 +00:00
tg 0d72355038 “local x=$1” is supposed to not field-split and so 2015-03-14 05:23:18 +00:00
tg 532af35304 oksh rcsid sync; we have no set -o csh-history, and the manpage changes are just wrong, so, a nop 2015-03-14 05:17:17 +00:00
tg bcff0752b4 another needed quote 2015-03-14 04:38:13 +00:00
tg 96d9e5d1f1 remove unused CMDWORD 2015-03-14 04:37:55 +00:00
tg f893c7a347 implement “enable” (like GNU bash) to stop Harzilein from complaining
about mksh’s “rename” builtin
2015-03-08 23:50:00 +00:00
tg 8f53c68265 • protect POSIX builtins and utilities from aliases, e.g:
‣ : → \:
  ‣ alias → \alias
    ⇒ except in some internally used cases, where we use \builtin alias
  ‣ command . → \command .
• protect Korn Shell builtins from aliases and functions, e.g:
  ‣ typeset → \builtin typeset
    ⇒ also unravels the “local” alias used
  ‣ print → \builtin print
• protect internally-used things from aliases
  ‣ “let]” is not a valid function name
  ‣ “set” is POSIX so we don’t expect anyone to override it in a function
• use “command -v” instead of “whence -p” (“which”) in most
  places; thanks izabera from #ed on IRC for pointing out
  that “command -v” is POSIX – except, “whence -p” a̲l̲w̲a̲y̲s̲ looks
  for an executable and shows its full pathname; “command -v”
  also resolves to aliases, functions and builtins, so only use
  it where it makes any sense (both never output to stderr)
• make most of dot.mkshrc work in the face of such aliases
  ‣ “ulimit -c” is used; this is not POSIX, and not portable;
    maybe we should make ulimit accept-and-ignore the most
    common limits even if the OS doesn’t use them?
• update list of builtin aliases in the manpage
2015-03-08 22:54:36 +00:00
tg fcc59eee48 remove some unused string pooling stuff 2015-03-08 21:30:22 +00:00
tg be147e3426 SECURITY: make “unset HISTFILE” really work
additionally, make “HISTFILE=” the same, document the truncation and
re-reading process’ further and already-known bugs; this needs work
2015-03-07 20:46:31 +00:00
tg d3f3c3ec22 it’s probably useful to define a marker like this, for automated patching,
e.g. in SuSE’s shells/mksh specfile, since they insist on a vendor patch,
as PLD does
2015-03-05 13:30:57 +00:00
tg 8546943535 KNF 2015-03-01 16:02:48 +00:00
tg e3acd9c76a MFC everything except the igli-inspired changes to jobs.c and the
.Ox Ns -inspired integer base changes .
That means: bugfixes, plus the new arguments to exec (feature)
2015-03-01 15:43:09 +00:00
tg 707add559f keep “set -x” disabled during PS4 expansion, to avoid infinite looping 2015-03-01 15:23:05 +00:00
tg 06045cf889 more IRC deliberation with igli (let’s hope the “const” works), plus style advice from Kernighan’s writs 2015-02-20 13:08:28 +00:00
tg 5efc48befd optimise a bit (nuke one redundant check), from igli via IRC 2015-02-20 12:43:22 +00:00
tg f4ae6f7508 can't set word=IFS_QUOTE if already IFS_WORD (something there)
or IFS_QUOTE (third dquote (second OQUOTE) in """something)
2015-02-20 07:14:30 +00:00
tg 73082b9292 • fixup here document expansion (regression wrt. pdksh 5.2.14)
• adjust testsuite (and write tons of new tests) after today’s commits
2015-02-19 22:26:50 +00:00
tg be1a0e3282 unbreak other cases where $@ shares double quotes with something else 2015-02-19 22:01:13 +00:00
tg 1248a0a521 basically unbreak use of $*/$@ in here documents
a bit funny:
with NUL IFS, $* behaves like dash ('ab') and $@ like bash/ksh93 ('a b')

with WS or NWS IFS, all shells behave alike though
2015-02-19 22:00:03 +00:00
tg ab683420df fix use of $*/$@ in scalar context in [[ … ]] and case; spotted by Stéphane Chazelas 2015-02-19 21:58:19 +00:00
tg 61cea6b71b another oksh rcsid-only sync 2015-02-16 15:10:15 +00:00
tg 4157cca352 oksh sync; unsure if it applies (with us using old_source and all) but
better be safe than sorry; it at least passes our testsuite

NOTE: people who can figure out how afl can be used for mksh welcome! ;-)
2015-02-13 12:51:33 +00:00
tg f6f49a119b add getopts for exec (unbreaks “exec -- /bin/ls”) and steal -a and -c from ksh93 2015-02-06 10:56:49 +00:00
tg b94b2e363a stop (ab)using the OS symbolic constant EOF, always use -1; plus misc fixes 2015-02-06 10:09:07 +00:00
tg f235766a3d int → bool 2015-02-06 09:42:46 +00:00
tg 3be80b75ed remove dead code: this can no longer happen since exec.c,v 1.67 2015-02-06 09:42:08 +00:00
tg 6f3d362785 rewrite the code a bit to avoid GCC -Wstrict-overflow triggering in one case…
most of it is utterly useless though as the line indicated is usually the
closing curly brace of a function, often not even the reported one…
2015-02-06 09:33:41 +00:00
tg 934929c2ee rcsid sync from obsd; misc sync; small improvements
• mksh testsuite no longer uses printf, again
• use MAXPATHLEN from <sys/param.h> as PATH_MAX fallback
2015-01-25 15:23:43 +00:00