Release calc 2.12.6.8

The following are the changes in this release:

    For historical purposes, in lucas.cal, gen_v1(1, n) always returns 4.

    Fixed some compiler warnings, thanks to a report by Mike
    <michael dot d dot ince at gmail dot com>.

    Added work around for a gcc warning bug, thanks to a report by Mike
    <michael dot d dot ince at gmail dot com>.

    Fixed errors in various help files such as:

	mat randbit seed srandom types

    Removed the MAXSTRING symbol because it was no longer used by calc.

    Increased HIST_SIZE (depth of the history stack) from 10k to 32k.

    Increased TTYSIZE (reallocation size for terminal buffers) from 100 to 8191.

    Increased MAXDEPTH (maximum depth of input stack) from 10 to 255.

    Increased interactive input buffer size from 1024 to 256k.  This has the
    effect of increasing the maximum length of an input line from a tty.
    This helps with an interactive bug that was reported by Ruslan Kabatsayev
    (b7 dot 10110111 at gmail dot com).

    The calc man page indicates that -d also disables the printing of the
    leading tilde.

    Added information to "help command" about how to silence messages
    while reading calc resource files.

    Fixed an error message buffer overflow thanks to a report by
    Frank Peters <nlp at northernlightsphoto dot biz>.

    Replaced all use of the C funcion sprintf() with snprintf().
    Replaced all use of the C funcion vsprintf() with vsnprintf().
    Replaced all DONT_HAVE_VSPRINTF with DONT_HAVE_VSNPRINTF.
    Replaced all Makefile var ${HAVE_VSPRINTF} with ${HAVE_VSNPRINTF}.
This commit is contained in:
Landon Curt Noll
2018-09-30 10:25:18 -07:00
parent e555a718c0
commit c8705c1198
20 changed files with 206 additions and 194 deletions

20
func.c
View File

@@ -1,7 +1,7 @@
/*
* func - built-in functions implemented here
*
* Copyright (C) 1999-2007 David I. Bell, Landon Curt Noll and Ernest Bowen
* Copyright (C) 1999-2007,2018 David I. Bell, Landon Curt Noll & Ernest Bowen
*
* Primary author: David I. Bell
*
@@ -6022,12 +6022,15 @@ f_strerror(int count, VALUE **vals)
/* firewall - return generic error string if it is not assigned */
if (i >= nexterrnum || (i > E__HIGHEST && i < E_USERDEF)
|| (i < E__BASE && strerror(i) == NULL)) {
cp = (char *) malloc(sizeof("Error 1234567890")+1);
size_t snprintf_len; /* malloced snprintf buffer length */
snprintf_len = sizeof("Unknown error 12345678901234567890")+1;
cp = (char *) malloc(snprintf_len+1);
if (cp == NULL) {
math_error("Out of memory for strerror");
/*NOTREACHED*/
}
sprintf(cp, "Unknown error %ld", i);
snprintf(cp, snprintf_len, "Unknown error %ld", i);
cp[snprintf_len] = '\0'; /* paranoia */
result.v_str = makestring(cp);
return result;
}
@@ -7550,6 +7553,8 @@ f_putenv(int count, VALUE **vals)
* parse args
*/
if (count == 2) {
size_t snprintf_len; /* malloced snprintf buffer length */
/* firewall */
if (vals[0]->v_type != V_STR || vals[1]->v_type != V_STR) {
math_error("Non-string argument for putenv");
@@ -7557,14 +7562,17 @@ f_putenv(int count, VALUE **vals)
}
/* convert putenv("foo","bar") into putenv("foo=bar") */
putenv_str = (char *)malloc(vals[0]->v_str->s_len + 1 +
vals[1]->v_str->s_len + 1);
snprintf_len = vals[0]->v_str->s_len + 1 +
vals[1]->v_str->s_len + 1;
putenv_str = (char *)malloc(snprintf_len+1);
if (putenv_str == NULL) {
math_error("Cannot allocate string in putenv");
/*NOTREACHED*/
}
sprintf(putenv_str, "%s=%s", vals[0]->v_str->s_str,
snprintf(putenv_str, snprintf_len,
"%s=%s", vals[0]->v_str->s_str,
vals[1]->v_str->s_str);
putenv_str[snprintf_len] = '\0'; /* paranoia */
} else {