Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security fixes #102

Merged
merged 3 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
id: cpu-cores
if: matrix.language == 'cpp'
- name: cmake
run: mkdir build && cd build && cmake ..
run: mkdir build && cd build && cmake .. -DUseLibCMAES=OFF
if: matrix.language == 'cpp'
- name: make
run: cd build && cmake --build . -j${{ steps.cpu-cores.outputs.count }}
Expand Down
12 changes: 7 additions & 5 deletions src/baryo_calculation/Fluid_Type/bot_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ void bot_source::operator()(const state_type &omega,
// TOP and BOT quark mass calculation
top_func(z, quark_mass, quark_mass_prime);
double mt = quark_mass[0];
double mb;
double mb{0};
// BOTTOM quark mass can be set to zero to have a crosscheck
if (bot_mass_flag == 1) mb = quark_mass[1];
if (bot_mass_flag == 2) mb = 0;
if ((bot_mass_flag != 1) and (bot_mass_flag != 2))
if (bot_mass_flag == 1)
mb = quark_mass[1];
else if (bot_mass_flag == 2)
mb = 0;
else
throw std::runtime_error("No valid option for the bottom mass @ ()");

// Phase Calculation
Expand Down Expand Up @@ -165,7 +167,7 @@ double bot_source::Calc_nL(double z_start, double z_end) const
mu = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const double C_AbsErr = 1e-9;
const double C_RelErr = 1e-5;
double stepsize_initial;
double stepsize_initial{0};
if (z_start < z_end) stepsize_initial = 1e-8;
if (z_start > z_end) stepsize_initial = -1e-8;
double abs_err = C_AbsErr;
Expand Down
8 changes: 4 additions & 4 deletions src/baryo_calculation/Fluid_Type/gen_func_fluid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ void Calc_eta::set_class(std::vector<double> array_z_in,
// SIMPLIFIED EXPRESSION
// prefactor = -3*GamWS/(2*vw*s_entr);
// exponent_prefactor = -R*GamWS/vw;
double t0, h;
double t0{0}, h{0};
if (array_z.at(0) < array_z.at(array_z.size() - 1))
{
t0 = array_z.at(0);
h = array_z.at(1) - array_z.at(0);
}
if (array_z.at(0) > array_z.at(array_z.size() - 1))
else if (array_z.at(0) > array_z.at(array_z.size() - 1))
{
t0 = array_z.at(array_z.size() - 1);
h = array_z.at(0) - array_z.at(1);
Expand Down Expand Up @@ -351,13 +351,13 @@ void Calc_eta::set_class(
// SIMPLIFIED EXPRESSION
// prefactor = -3*GamWS/(2*vw*s_entr);
// exponent_prefactor = -R*GamWS/vw;
double t0, h;
double t0{0}, h{0};
if (array_z.at(0) < array_z.at(array_z.size() - 1))
{
t0 = array_z.at(0);
h = array_z.at(1) - array_z.at(0);
}
if (array_z.at(0) > array_z.at(array_z.size() - 1))
else if (array_z.at(0) > array_z.at(array_z.size() - 1))
{
t0 = array_z.at(array_z.size() - 1);
h = array_z.at(0) - array_z.at(1);
Expand Down
28 changes: 17 additions & 11 deletions src/baryo_calculation/Fluid_Type/tau_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,23 @@ void tau_source::operator()(const state_type &omega,
// TOP and BOT quark mass calculation
top_func(z, quark_mass, quark_mass_prime);
double mt = quark_mass[0];
double mb;
if (bot_mass_flag == 1) mb = quark_mass[1];
if (bot_mass_flag == 2) mb = 0;
if ((bot_mass_flag != 1) and (bot_mass_flag != 2))
double mb{0};
if (bot_mass_flag == 1)
mb = quark_mass[1];
else if (bot_mass_flag == 2)
mb = 0;
else
throw std::runtime_error("No valid mbot mass flag is chosen. Please make "
"sure to chose a proper value");
// TAU mass calculation
std::vector<double> tau_mass, tau_mass_prime;
tau_func(z, tau_mass, tau_mass_prime);
double mtau;
if (tau_mass_flag == 1) mtau = tau_mass[0];
if (tau_mass_flag == 2) mtau = 0;
if ((tau_mass_flag != 1) and (tau_mass_flag != 2))
double mtau{0};
if (tau_mass_flag == 1)
mtau = tau_mass[0];
else if (tau_mass_flag == 2)
mtau = 0;
else
throw std::runtime_error("No valid mtau mass flag is chosen. Please make "
"sure to chose a proper value");

Expand Down Expand Up @@ -222,9 +226,11 @@ double tau_source::Calc_nL(double z_start, double z_end) const
mu = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const double C_AbsErr = 1e-9;
const double C_RelErr = 1e-5;
double stepsize_initial;
if (z_start < z_end) stepsize_initial = 1e-8;
if (z_start > z_end) stepsize_initial = -1e-8;
double stepsize_initial{0};
if (z_start < z_end)
stepsize_initial = 1e-8;
else
stepsize_initial = -1e-8;
double abs_err = C_AbsErr;
double rel_err = C_RelErr;
integrate_adaptive(make_controlled(abs_err, rel_err, error_stepper_type()),
Expand Down
8 changes: 5 additions & 3 deletions src/baryo_calculation/Fluid_Type/top_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ double top_source::Calc_nL(double z_start, double z_end) const
mu = {0, 0, 0, 0, 0, 0, 0, 0};
const double C_AbsErr = 1e-9;
const double C_RelErr = 1e-5;
double stepsize_initial;
if (z_start < z_end) stepsize_initial = 1e-8;
if (z_start > z_end) stepsize_initial = -1e-8;
double stepsize_initial{0};
if (z_start < z_end)
stepsize_initial = 1e-8;
else
stepsize_initial = -1e-8;
double abs_err = C_AbsErr;
double rel_err = C_RelErr;
integrate_adaptive(make_controlled(abs_err, rel_err, error_stepper_type()),
Expand Down
6 changes: 3 additions & 3 deletions src/minimizer/Minimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ namespace Minimizer

MinimizersToUse GetMinimizers(int WhichMinimizer)
{
bool UseCMAES = (WhichMinimizer % 2 == 1);
bool UseCMAES = (WhichMinimizer % 2 != 0);
WhichMinimizer /= 2;
bool UseGSL = (WhichMinimizer % 2 == 1);
bool UseGSL = (WhichMinimizer % 2 != 0);
WhichMinimizer /= 2;
bool UseNLopt = (WhichMinimizer % 2 == 1);
bool UseNLopt = (WhichMinimizer % 2 != 0);

#ifndef libcmaes_FOUND
UseCMAES = false;
Expand Down