clang was rightly complaining about this, so let's just fix it.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
clang was rightly complaining about this, so let's just fix it.
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | contrib/fuzz/pyutil.cc (7 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 0a2d0223a588 | 982a91c23849 | Augie Fackler | Dec 6 2019, 3:30 PM |
| #include "pyutil.h" | #include "pyutil.h" | ||||
| #include <iostream> | |||||
| #include <string> | #include <string> | ||||
| namespace contrib | namespace contrib | ||||
| { | { | ||||
| static char cpypath[8192] = "\0"; | static char cpypath[8192] = "\0"; | ||||
| static PyObject *mainmod; | static PyObject *mainmod; | ||||
| static PyObject *globals; | static PyObject *globals; | ||||
| /* TODO: use Python 3 for this fuzzing? */ | /* TODO: use Python 3 for this fuzzing? */ | ||||
| PyMODINIT_FUNC initparsers(void); | PyMODINIT_FUNC initparsers(void); | ||||
| void initpy(const char *cselfpath) | void initpy(const char *cselfpath) | ||||
| { | { | ||||
| const std::string subdir = "/sanpy/lib/python2.7"; | const std::string subdir = "/sanpy/lib/python2.7"; | ||||
| /* HACK ALERT: we need a full Python installation built without | /* HACK ALERT: we need a full Python installation built without | ||||
| pymalloc and with ASAN, so we dump one in | pymalloc and with ASAN, so we dump one in | ||||
| $OUT/sanpy/lib/python2.7. This helps us wire that up. */ | $OUT/sanpy/lib/python2.7. This helps us wire that up. */ | ||||
| std::string selfpath(cselfpath); | std::string selfpath(cselfpath); | ||||
| std::string pypath; | std::string pypath; | ||||
| auto pos = selfpath.rfind("/"); | auto pos = selfpath.rfind("/"); | ||||
| if (pos == std::string::npos) { | if (pos == std::string::npos) { | ||||
| char wd[8192]; | char wd[8192]; | ||||
| getcwd(wd, 8192); | if (!getcwd(wd, 8192)) { | ||||
| std::cerr << "Failed to call getcwd: errno " << errno | |||||
| << std::endl; | |||||
| exit(1); | |||||
| } | |||||
| pypath = std::string(wd) + subdir; | pypath = std::string(wd) + subdir; | ||||
| } else { | } else { | ||||
| pypath = selfpath.substr(0, pos) + subdir; | pypath = selfpath.substr(0, pos) + subdir; | ||||
| } | } | ||||
| strncpy(cpypath, pypath.c_str(), pypath.size()); | strncpy(cpypath, pypath.c_str(), pypath.size()); | ||||
| setenv("PYTHONPATH", cpypath, 1); | setenv("PYTHONPATH", cpypath, 1); | ||||
| setenv("PYTHONNOUSERSITE", "1", 1); | setenv("PYTHONNOUSERSITE", "1", 1); | ||||
| /* prevent Python from looking up users in the fuzz environment */ | /* prevent Python from looking up users in the fuzz environment */ | ||||