Commits on Oct 24, 2018
  1. Fix a bug found by ASAN after enabling builtins

    krader1961 committed Oct 23, 2018
    Properly null terminate the dynamically allocated string. This reduces
    unit test failures under ASAN on my system from 128 to 43.
    Related #969
Commits on Oct 23, 2018
  1. Return 1 from `signbit` function if sign bit is set

    siteshwar committed Oct 21, 2018
    `signbit` function prints 512 on Linux if sign bit is set. It should
    print 1 to make the result more clear.
    Resolves: #967
  2. Revert builtin `chmod` workarounds

    krader1961 committed Oct 20, 2018
    The builtin `chmod` command is once again able to handle more than one
    pathname. So revert the workarounds from my earlier commit which enabled
    builtins for all unit tests.
    Related #949
  3. Add feature test for `lchmod()`

    krader1961 committed Oct 20, 2018
    The builtin `chmod` needs to know if the platform provides `lchmod()` to
    provide its full functionality.
    Related #949
  4. Fix chmod handling of multiple paths

    krader1961 committed Oct 20, 2018
    Fixes #949
Commits on Oct 21, 2018
Commits on Oct 20, 2018
  1. Workaround builtin cat bug

    krader1961 committed Oct 20, 2018
    Three more uses of `cat /dev/fd/3` that have to use the external command
    due to the as yet unresolved defect with the builtin.
    Related #951
    Related #965
Commits on Oct 19, 2018
  1. bin/style all

    krader1961 committed Oct 19, 2018
  2. Replace stpcpy() with strlcpy()

    krader1961 committed Oct 17, 2018
    This only does so for one place where it matters. It replaces `stcpy()`
    with `strcpy()` where the return value doesn't matter. It leaves the uses
    in getopt.c because we want to eliminate that code. It leaves the other
    uses in glob.c because a simple replacement of one function for another
    doesn't address the core problems with those uses of stpcpy.
    Resolves #956
  3. Use builtins in unit tests by default

    krader1961 committed Oct 9, 2018
    The default behavior of unit tests should be to use builtins when
    available and using external commands of the same name should be done
    explicitly. This will help ensure builtins behave sensibly even if there
    are insufficient explicit tests of each builtin.
    Resolves #944
Commits on Oct 18, 2018
  1. Fix a memory corruption issue in default path

    siteshwar committed Oct 18, 2018
    `astconf()` function internally uses `fmtbuf()` to allocate memory.
    Memory allocated by this function is short-lived and should not be
    directly used in global variables, so duplicate the string returned by
    `astconf()` function.
    Resolves: #959
Commits on Oct 16, 2018
  1. Compatibility of ulimit unit tests

    krader1961 committed Oct 15, 2018
    Some platforms (e.g., OpenBSD and FreeBSD) don't allow changing some
    ulimit thresholds. Modify the unit test to skip those tests on those
    Fixes #957
Commits on Oct 14, 2018
  1. Implement an `eaccess()` fallback

    krader1961 committed Oct 10, 2018
    Some systems we want to support don't provide `faccessat()` or `eaccess()`
    or `eaccessuid()`. So implement build time feature tests and provide
    fallback implementations.
    Resolves #941
Commits on Oct 11, 2018
  1. Include stdlib.h when checking for mkostemp

    krader1961 committed Oct 11, 2018
    On most platforms `mkostemp()` is declared in stdlib.h but on macOS it
    is in unistd.h so include both headers in the feature test.
Commits on Oct 9, 2018
  1. Lint cleanup

    krader1961 committed Oct 9, 2018
    src/cmd/ksh93/sh/lex.c:1128:21: prefer early exits and continue
    [convention|P3] Use early exit/continue to simplify code and reduce
Commits on Oct 8, 2018
  1. Remove lint from module io.c

    krader1961 committed Oct 6, 2018
    Clang static analysis reports:
    src/cmd/ksh93/sh/io.c:541:14: Potential leak of memory pointed to by 's'
    This eliminates that lint warning and also restructures the code to clarify
    the behavior. As always, this type of change is not meant to address
    every shortcoming of the code being modified. It's only meant to be an
    incremental step to improving the quality by eliminating a lint warning.
    Related #853
  2. Lint cleanup

    krader1961 committed Oct 8, 2018
    Oclint warns:
    src/lib/libast/regex/regnexec.c:1743:21: prefer early exits and continue
    [convention|P3] Use early exit/continue to simplify code and reduce
    Resolves #940
  3. Lint cleanup

    krader1961 committed Oct 8, 2018
    src/lib/libast/regex/regnexec.c:1313:25: prefer early exits and continue
    [convention|P3] Use early exit/continue to simplify code and reduce
  4. Lint cleanup

    krader1961 committed Oct 8, 2018
    src/lib/libast/regex/regnexec.c:1798:23: The right operand of '>' is a
    garbage value
    It's theoretically possible for the `i > n` condition to be evaluated
    without `n` being assigned to. It probably can't happen in practice but
    it's easy enough to initialize `n` where it is defined to ensure we
    don't use whatever random value was on the stack.
  5. Lint cleanup

    krader1961 committed Oct 8, 2018
    src/lib/libast/regex/regstat.c:44:25: Access to field 'type' results in
    a dereference of a null pointer (loaded from field 'rex')
    The `p && p->env` conditions don't make any sense since both have to be
    non-NULL at that point. However, it is possible for `p->env->rex` to be
    NULL so that needs to be tested before dereferencing it to get the
    `type` value.
  6. Lint cleanup

    krader1961 committed Oct 8, 2018
    src/lib/libast/sfio/sfgetr.c:145:20: Array access (from variable 'us')
    results in a null pointer dereference

    krader1961 committed Oct 7, 2018
    I checked the beta (93v-) branch and am pretty sure we introduced
    the LIBICONV_PLUG hack because the code had stuff like this in
    printf("#undef  iconv_open\n");
    printf("#define iconv_open      %siconv_open\n", lib);
    printf("extern %siconv_t        %siconv_open(const char*, const char*);\n", lib, lib);
    That ended up dynamically constructing the ast_iconv.h header which
    contained entries like this which varies depending on whether or not the
    feature test determined that the "lib" prefix was needed:
    For expediency we generated the ast_iconv.h using the legacy IFFE
    mechanism one time on Linux then checked it into the project. It was
    only when I started working on getting ksh to build on other platforms
    that we found the problem with that #define above. Since then I removed
    that header as part of my removal of all the AST locale code that ksh
    didn't need or that we didn't want to support.
    Resolves #932
  8. Remove unnecessary header `ls.h`

    krader1961 committed Oct 7, 2018
    It now contains exactly one symbol that is still needed: the prototype for
    `pathstat()`. So move that declaration in to `ast.h` and remove `ls.h`.
  9. Remove unused `procrun()`

    krader1961 committed Oct 7, 2018