Permalink
Commits on Nov 12, 2018
  1. bin/style all

    krader1961 committed Nov 12, 2018
  2. Disable sigqueue() on WSL

    krader1961 committed Nov 12, 2018
    The `sigqueue()` function doesn't work at present on WSL even though
    the interface is present.
Commits on Nov 11, 2018
  1. Coverity CID#326342 Logically dead code

    krader1961 committed Nov 11, 2018
    The `close(arg2)` should only be done if we had to use the fallback
    because TIOCSCTTY wasn't defined.
Commits on Nov 10, 2018
  1. Coverity CID#253829 Resource leak

    krader1961 committed Nov 10, 2018
    The memory pointed to by `np` isn't leaked because the `dtinsert()`
    saves a pointer to the memory. But Coverity Scan has no way of knowning
    the loop has to run at least once. The `assert()` this adds both ensures
    that condition is true and hopefully silences Coverity Scan.
  2. Coverity CID#287603 Resource leak

    krader1961 committed Nov 10, 2018
    This fixes a potential leak of a file descriptor. In practice this can't
    happen except for pathological situations. Specifically, the open()
    succeeds but the subsequent fstat() fails because of an OS or network
    file system glitch.
  3. Coverity CID#325858 Resource leak

    krader1961 committed Nov 10, 2018
    The way in which `optctx()` is being used leaks memory. And since `sh_run()`
    is the only user of the function, and that use is completely superfluous,
    just remove it.
  4. Coverity Scan CID#253837 Resource leak

    krader1961 committed Nov 10, 2018
    This is yet another case of a problem due to returning control to the
    calling function when a dynamic memory allocation fails. Even though the
    caller does not handle that failure. In this case it simply makes more
    sense to die at the earliest opportunity.
    
    Related #853
  5. Remove all support for fixed size arrays

    krader1961 committed Nov 8, 2018
    Commit 54cd98f removed support for fixed size arrays by removing the
    `SHOPT_FIXEDARRAY` symbol and code predicated on it. While looking into
    how to resolve issue #1002 I noticed there is a structure member and a
    few bits of code that are no longer relevant as a result of that earlier
    change. This change completes the work started by that previous commit.
    
    Related #1002
  6. Use `is_associative()`

    krader1961 committed Nov 8, 2018
    Don't directly test if a structure member is set to decide if Namarr_t
    is an associative array or not. Use the `is_associative()` macro.
    
    Related #1002
  7. Rename `header` member to `namarr`

    krader1961 committed Nov 8, 2018
    Using generic names like `header` is bad practice. Especially since in
    this case the Namarr_t structure itself has a `hdr` member. So rename
    `header` to `namarr`.
    
    Related #1002
  8. Rename `array_assoc()`

    krader1961 committed Nov 8, 2018
    The existing `array_assoc()` name is not clear about its purpose. Replace
    it with `is_associative()` from array.c. But without the explicit cast
    since that can hide bugs and should not be needed.
    
    Related #1002
  9. First step is cleanup of array.c

    krader1961 committed Nov 8, 2018
    There are way too many unnecessary casts and intermediate vars that serve
    only to obfuscate the code. This is one tiny step in simplifying matters
    in preparation of making `struct index_array` fixed size and moving the
    variable portion into a separately allocated buffer.
    
    Related #1002
  10. Coverity Scan CID#279480 Out-of-bounds read

    krader1961 committed Nov 10, 2018
    The code attempts to output information found in `struct utsname` that
    it doesn't otherwise explicitly handle. This relies on an invalid
    assumption about the layout of the structure. Furthermore, outputting
    unknown structure members in an undefined order is not useful.
    
    Fixes #1004
  11. Remove namval.h

    krader1961 committed Nov 9, 2018
    The `Namval_t` structure defined in src/lib/libast/include/namval.h has
    absolutely nothing to do with the structure of the same name that is the
    core structure for ksh variable handling. This unrelated structure is
    used in just three modules to define lists of options for the `stropt()`
    function.  There isn't any reason to maintain a separate header for
    this trivial structure. So define it in each of the three modules that
    use it and give it a different name to avoid confusion with the other,
    far more important, `Namval_t` type.
Commits on Nov 7, 2018
  1. Coverity: resource leak

    krader1961 committed Nov 7, 2018
    Eliminate a theoretical memory leak. Theoretical because in practice it
    can only happen if the situation is already FUBAR in which case the leak
    probably doesn't matter.
    
    Coverity CID#253834
  2. Coverity: resource leak

    krader1961 committed Nov 7, 2018
    Coverity CID#287611
  3. Reinstate seemingly pointless casts

    krader1961 committed Nov 7, 2018
    My previous change dropped some seemingly pointless casts. But they're
    needed due to the poor structure of the code so reinstate them.
  4. Coverity: resource leak

    krader1961 committed Nov 7, 2018
    Coverity CID#288380
  5. oclint: heap-use-after-free

    krader1961 committed Nov 7, 2018
    The `substring` unit test revealed a heap-use-after-free error in the
    `varsub()` function because it may use a stale Namarr_t pointer after
    calling `putsub()` which reallocated that structure in order to grow it.
    
    Related #1002
Commits on Nov 6, 2018
  1. oclint: multiple unary operator

    krader1961 committed Nov 5, 2018
    The `!!procfd` is not needed since the value has to be zero or one at
    that point. Thus there is no need to coerce all non-zero values to one
    since the only non-zero value it can have is one.
  2. bin/style all

    krader1961 committed Nov 5, 2018
Commits on Nov 5, 2018
  1. oclint: prefer early exits and continue

    krader1961 committed Nov 5, 2018
    Restructure the `modify()` function to shorten and clarify its behavior.
  2. Coverity: string not null terminated

    krader1961 committed Nov 5, 2018
    There is a theoretical, albeit very unlikely to be seen in practice, bug
    that can result in a string buffer not explicitly null terminated being
    passed to a function which requires that data type. Nonetheless, this is
    a bug so fix it.
    
    Coverity CID#294196
  3. IWYU cleanup

    krader1961 committed Nov 5, 2018
    The previous change to remove pre-2012, legacy, APIs introduced some
    changes with respect to the proper header includes.
  4. oclint: empty if block

    krader1961 committed Nov 5, 2018
  5. oclint: empty if body

    krader1961 committed Nov 5, 2018