vendor/bc: import release 5.2.2
This release assigns a default value to the internal program name variable in case the program is invoked with argv[0] == NULL. There was no security issue: the prevuous program version would have been immediately terminated due to a NULL dereference.
This commit is contained in:
parent
c999e3481d
commit
00698711de
@ -1,5 +1,13 @@
|
|||||||
# News
|
# News
|
||||||
|
|
||||||
|
## 5.2.2
|
||||||
|
|
||||||
|
This is a production release that fixes one bug, a segmentation fault if
|
||||||
|
`argv[0]` equals `NULL`.
|
||||||
|
|
||||||
|
This is not a critical bug; there will be no vulnerability as far as I can tell.
|
||||||
|
There is no need to update if you do not wish to.
|
||||||
|
|
||||||
## 5.2.1
|
## 5.2.1
|
||||||
|
|
||||||
This is a production release that fixes two parse bugs when in POSIX standard
|
This is a production release that fixes two parse bugs when in POSIX standard
|
||||||
|
@ -36,7 +36,7 @@ builddir=$(pwd)
|
|||||||
. "$scriptdir/scripts/functions.sh"
|
. "$scriptdir/scripts/functions.sh"
|
||||||
|
|
||||||
# Simply prints the help message and quits based on the argument.
|
# Simply prints the help message and quits based on the argument.
|
||||||
# @param val The value to pass to exit. Must be an integer.
|
# @param msg The help message to print.
|
||||||
usage() {
|
usage() {
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
@ -95,7 +95,7 @@ usage() {
|
|||||||
printf ' -f, --force\n'
|
printf ' -f, --force\n'
|
||||||
printf ' Force use of all enabled options, even if they do not work. This\n'
|
printf ' Force use of all enabled options, even if they do not work. This\n'
|
||||||
printf ' option is to allow the maintainer a way to test that certain options\n'
|
printf ' option is to allow the maintainer a way to test that certain options\n'
|
||||||
printf ' are not failing invisibly. (Development only.)'
|
printf ' are not failing invisibly. (Development only.)\n'
|
||||||
printf ' -g, --debug\n'
|
printf ' -g, --debug\n'
|
||||||
printf ' Build in debug mode. Adds the "-g" flag, and if there are no\n'
|
printf ' Build in debug mode. Adds the "-g" flag, and if there are no\n'
|
||||||
printf ' other CFLAGS, and "-O" was not given, this also adds the "-O0"\n'
|
printf ' other CFLAGS, and "-O" was not given, this also adds the "-O0"\n'
|
||||||
@ -535,7 +535,7 @@ gen_std_test_targets() {
|
|||||||
# This allows `make test_bc_errors` and `make test_dc_errors` to run in
|
# This allows `make test_bc_errors` and `make test_dc_errors` to run in
|
||||||
# parallel.
|
# parallel.
|
||||||
#
|
#
|
||||||
# @param name Which calculator to generate tests for.
|
# @param name Which calculator to generate tests for.
|
||||||
gen_err_tests() {
|
gen_err_tests() {
|
||||||
|
|
||||||
_gen_err_tests_name="$1"
|
_gen_err_tests_name="$1"
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
#define BC_LANG_H
|
#define BC_LANG_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#if BC_C11
|
||||||
|
#include <assert.h>
|
||||||
|
#endif // BC_C11
|
||||||
|
|
||||||
#include <status.h>
|
#include <status.h>
|
||||||
#include <vector.h>
|
#include <vector.h>
|
||||||
@ -324,6 +327,11 @@ typedef enum BcInst {
|
|||||||
|
|
||||||
} BcInst;
|
} BcInst;
|
||||||
|
|
||||||
|
#if BC_C11
|
||||||
|
static_assert(BC_INST_INVALID <= UCHAR_MAX,
|
||||||
|
"Too many instructions to fit into an unsigned char");
|
||||||
|
#endif // BC_C11
|
||||||
|
|
||||||
/// Used by maps to identify where items are in the array.
|
/// Used by maps to identify where items are in the array.
|
||||||
typedef struct BcId {
|
typedef struct BcId {
|
||||||
|
|
||||||
|
@ -37,6 +37,6 @@
|
|||||||
#define BC_VERSION_H
|
#define BC_VERSION_H
|
||||||
|
|
||||||
/// The current version.
|
/// The current version.
|
||||||
#define VERSION 5.2.1
|
#define VERSION 5.2.2
|
||||||
|
|
||||||
#endif // BC_VERSION_H
|
#endif // BC_VERSION_H
|
||||||
|
@ -545,8 +545,10 @@ typedef struct BcVm {
|
|||||||
/// The messages for each error.
|
/// The messages for each error.
|
||||||
const char *err_msgs[BC_ERR_NELEMS];
|
const char *err_msgs[BC_ERR_NELEMS];
|
||||||
|
|
||||||
|
#if BC_ENABLE_NLS
|
||||||
/// The locale.
|
/// The locale.
|
||||||
const char *locale;
|
const char *locale;
|
||||||
|
#endif // BC_ENABLE_NLS
|
||||||
|
|
||||||
#endif // !BC_ENABLE_LIBRARY
|
#endif // !BC_ENABLE_LIBRARY
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if BC_ENABLE_NLS
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#endif // BC_ENABLE_NLS
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
@ -56,16 +58,34 @@ int main(int argc, char *argv[]) {
|
|||||||
char *name;
|
char *name;
|
||||||
size_t len = strlen(BC_EXECPREFIX);
|
size_t len = strlen(BC_EXECPREFIX);
|
||||||
|
|
||||||
|
#if BC_ENABLE_NLS
|
||||||
// Must set the locale properly in order to have the right error messages.
|
// Must set the locale properly in order to have the right error messages.
|
||||||
vm.locale = setlocale(LC_ALL, "");
|
vm.locale = setlocale(LC_ALL, "");
|
||||||
|
#endif // BC_ENABLE_NLS
|
||||||
|
|
||||||
// Set the start pledge().
|
// Set the start pledge().
|
||||||
bc_pledge(bc_pledge_start, NULL);
|
bc_pledge(bc_pledge_start, NULL);
|
||||||
|
|
||||||
// Figure out the name of the calculator we are using. We can't use basename
|
// Sometimes, argv[0] can be NULL. Better make sure to be robust against it.
|
||||||
// because it's not portable, but yes, this is stripping off the directory.
|
if (argv[0] != NULL) {
|
||||||
name = strrchr(argv[0], BC_FILE_SEP);
|
|
||||||
vm.name = (name == NULL) ? argv[0] : name + 1;
|
// Figure out the name of the calculator we are using. We can't use
|
||||||
|
// basename because it's not portable, but yes, this is stripping off
|
||||||
|
// the directory.
|
||||||
|
name = strrchr(argv[0], BC_FILE_SEP);
|
||||||
|
vm.name = (name == NULL) ? argv[0] : name + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if !DC_ENABLED
|
||||||
|
vm.name = "bc";
|
||||||
|
#elif !BC_ENABLED
|
||||||
|
vm.name = "dc";
|
||||||
|
#else
|
||||||
|
// Just default to bc in that case.
|
||||||
|
vm.name = "bc";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// If the name is longer than the length of the prefix, skip the prefix.
|
// If the name is longer than the length of the prefix, skip the prefix.
|
||||||
if (strlen(vm.name) > len) vm.name += len;
|
if (strlen(vm.name) > len) vm.name += len;
|
||||||
|
@ -2718,7 +2718,6 @@ void bc_program_exec(BcProgram *p) {
|
|||||||
while (ip->idx < func->code.len)
|
while (ip->idx < func->code.len)
|
||||||
#endif // !BC_HAS_COMPUTED_GOTO
|
#endif // !BC_HAS_COMPUTED_GOTO
|
||||||
{
|
{
|
||||||
|
|
||||||
BC_SIG_ASSERT_NOT_LOCKED;
|
BC_SIG_ASSERT_NOT_LOCKED;
|
||||||
|
|
||||||
#if BC_HAS_COMPUTED_GOTO
|
#if BC_HAS_COMPUTED_GOTO
|
||||||
|
Loading…
Reference in New Issue
Block a user