Fixed internal code bugs

Fixed a really obscure bug in the internal initconstants()
function of const.c that has been sitting for over 31 years!

    We are amazed that nobody has encountered this bug before
    now.  Nevertheless, our very extensive regression and
    multi-architecture testing found the bug.  Now, after all
    those years, it is fixed.

Fixed issues identied by the default CodeUL GitHub security code scan:

    Wrong type of arguments to printf in have_fpos_pos.c
    Multiplication result converted to larger type in zfunc.c
This commit is contained in:
Landon Curt Noll
2021-10-22 03:05:12 -07:00
parent 99ac7836aa
commit 286233e28f
2 changed files with 17 additions and 1 deletions

13
CHANGES
View File

@@ -197,6 +197,19 @@ The following are the changes from calc version 2.14.0.0 to date:
Fixed an old Windoz pun in README.WINDOWS as requested by <GitHub
user marcodegio>.
Fixed a really obscure bug in the internal initconstants()
function of const.c that has been sitting for over 31 years!
We are amazed that nobody has encountered this bug before
now. Nevertheless, our very extensive regression and
multi-architecture testing found the bug. Now, after all
those years, it is fixed.
Fixed issues identied by the default CodeUL GitHub security code scan:
Wrong type of arguments to printf in have_fpos_pos.c
Multiplication result converted to larger type in zfunc.c
The following are the changes from calc version 2.13.0.1 to 2.13.0.1:

View File

@@ -49,7 +49,7 @@ initconstants(void)
math_error("Unable to allocate constant table");
/*NOTREACHED*/
}
for (i = 0; consttable[i] != NULL; i++) {
for (i = 0; initnumbs[i] != NULL; i++) {
consttable[i] = initnumbs[i];
}
constcount = i-1;
@@ -123,6 +123,9 @@ addqconstant(NUMBER *q)
tp = consttable;
for (index = 0; index < constcount; index++, tp++) {
t = *tp;
if (t == NULL) { /* paranoia */
break;
}
if (t->links == 0) {
if (!havefirst) {
havefirst = TRUE;