File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -472,18 +472,15 @@ qmckl_get_error(qmckl_context context,
472
472
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
473
473
assert (ctx != NULL); /* Impossible because the context is valid. */
474
474
475
- /* Turn off annoying GCC warning */
476
- #ifdef __GNUC__
477
- #pragma GCC diagnostic push
478
- #pragma GCC diagnostic ignored "-Wstringop-truncation"
479
- #endif
475
+ size_t sizeCp;
480
476
481
- strncpy(function_name, ctx->error.function, QMCKL_MAX_FUN_LEN-1);
482
- strncpy(message , ctx->error.message , QMCKL_MAX_MSG_LEN-1);
477
+ sizeCp = strlen(ctx->error.function);
478
+ sizeCp = sizeCp > QMCKL_MAX_FUN_LEN ? QMCKL_MAX_FUN_LEN : sizeCp;
479
+ memcpy(function_name, ctx->error.function, sizeCp);
483
480
484
- #ifdef __GNUC__
485
- #pragma GCC diagnostic pop
486
- #endif
481
+ sizeCp = strlen(ctx->error.message);
482
+ sizeCp = sizeCp > QMCKL_MAX_MSG_LEN ? QMCKL_MAX_MSG_LEN : sizeCp;
483
+ memcpy(message, ctx->error.message, sizeCp);
487
484
488
485
(*exit_code) = ctx->error.exit_code;
489
486
}
You can’t perform that action at this time.
0 commit comments