diff options
author | Yang Rong <rong.r.yang@intel.com> | 2015-02-13 14:38:02 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-02-13 14:12:50 +0800 |
commit | 1c24f07213bcf302ffd6cc751f575dba10f1518d (patch) | |
tree | 87dfba4c2819a73a26eaefab8689bda44ce7b5ef | |
parent | b4c4fa99553381f096e87da4c5f198a15cda373b (diff) |
Correct the error llvm link msg copy in function genProgramLinkFromLLVM.
Use strncpy to avoid overflow and need return errSize.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | backend/src/backend/gen_program.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp index 6ad5eef0..1b296fb0 100644 --- a/backend/src/backend/gen_program.cpp +++ b/backend/src/backend/gen_program.cpp @@ -386,10 +386,9 @@ namespace gbe { if (LLVMLinkModules(wrap(dst), wrap(src), 0, &errMsg)) { #endif if (err != NULL && errSize != NULL && stringSize > 0u) { - if(strlen(errMsg) < stringSize ) - stringSize = strlen(errMsg); - strcpy(err, errMsg); - err[stringSize+1] = '\0'; + strncpy(err, errMsg, stringSize-1); + err[stringSize-1] = '\0'; + *errSize = strlen(err); } } } |