Unverified Commit 9843506e authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[ci] Changed use of strcpy to snprintf (fixes #1990) (#2973)

* [ci] Changed use of strcpy to snprintf

* fix

* fully enable cpplint
parent 7d5bfdaf
...@@ -56,7 +56,7 @@ if [[ $TRAVIS == "true" ]] && [[ $TASK == "lint" ]]; then ...@@ -56,7 +56,7 @@ if [[ $TRAVIS == "true" ]] && [[ $TASK == "lint" ]]; then
echo "Linting R code" echo "Linting R code"
Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1 Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1
echo "Linting C++ code" echo "Linting C++ code"
cpplint --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length --recursive ./src ./include || exit 0 cpplint --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length --recursive ./src ./include || exit -1
exit 0 exit 0
fi fi
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <LightGBM/export.h> #include <LightGBM/export.h>
#include <cstdint> #include <cstdint>
#include <cstdio>
#include <cstring> #include <cstring>
...@@ -1074,7 +1075,8 @@ static char* LastErrorMsg() { static THREAD_LOCAL char err_msg[512] = "Everythin ...@@ -1074,7 +1075,8 @@ static char* LastErrorMsg() { static THREAD_LOCAL char err_msg[512] = "Everythin
* \param msg Error message * \param msg Error message
*/ */
inline void LGBM_SetLastError(const char* msg) { inline void LGBM_SetLastError(const char* msg) {
std::strcpy(LastErrorMsg(), msg); const int err_buf_len = 512;
snprintf(LastErrorMsg(), err_buf_len, "%s", msg);
} }
#endif // LIGHTGBM_C_API_H_ #endif // LIGHTGBM_C_API_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment