Skip to content

Commit

Permalink
Use PY_VERSION_HEX for a cleaner CVE-2008-5983 mode check.
Browse files Browse the repository at this point in the history
  • Loading branch information
drmoose committed Aug 28, 2020
1 parent 3aa548f commit 1d7f2b3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/pybind11/embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ inline void set_interpreter_argv(int argc, char** argv, bool add_current_dir_to_
auto pysys_argv = safe_argv;
#endif

#if PY_MAJOR_VERSION == 2 && (PY_MINOR_VERSION < 6 || (PY_MINOR_VERSION == 6 && PY_MICRO_VERSION < 6)) || \
PY_MAJOR_VERSION == 3 && (PY_MINOR_VERSION < 1 || (PY_MINOR_VERSION == 1 && PY_MICRO_VERSION < 3))
// These python versions don't have PySys_SetArgvEx, so we have to use the workaround
#if PY_VERSION_HEX < 0x020606f0 || (PY_MAJOR_VERSION == 3 && PY_VERSION_HEX < 0x030103f0
// These python versions don't have PySys_SetArgvEx, so we have to use the approach
// recommended by https://docs.python.org/3.5/c-api/init.html#c.PySys_SetArgvEx
// to work around CVE-2008-5983
PySys_SetArgv(argc, pysys_argv);
Expand Down

0 comments on commit 1d7f2b3

Please sign in to comment.