[Beignet] [PATCH] Correct the error llvm link msg copy in function genProgramLinkFromLLVM.
Zhigang Gong
zhigang.gong at linux.intel.com
Thu Feb 12 22:08:48 PST 2015
LGTM, pushed, thanks.
On Fri, Feb 13, 2015 at 02:38:02PM +0800, Yang Rong wrote:
> Use strncpy to avoid overflow and need return errSize.
>
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
> backend/src/backend/gen_program.cpp | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
> index 65a7ba2..2525825 100644
> --- a/backend/src/backend/gen_program.cpp
> +++ b/backend/src/backend/gen_program.cpp
> @@ -394,10 +394,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);
> }
> }
> }
> --
> 1.8.3.2
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list