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
echo "Linting R code"
Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1
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
fi
......
......@@ -16,6 +16,7 @@
#include <LightGBM/export.h>
#include <cstdint>
#include <cstdio>
#include <cstring>
......@@ -1074,7 +1075,8 @@ static char* LastErrorMsg() { static THREAD_LOCAL char err_msg[512] = "Everythin
* \param msg Error message
*/
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_
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