More changes from NetBSD:
More changes from NetBSD:

     * use correct error detection of realloc failure
     * strtol negative return check
     * use strtol to validate string instead of rolling our own
       validation code
     * terminate the command sequence correctly

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase