1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-08 22:08:02 +00:00

Make sure log string is null-terminated.

This commit is contained in:
troky 2014-06-11 00:11:11 +02:00
parent fd35c77c82
commit 24fa44e12b
2 changed files with 3 additions and 2 deletions

View File

@ -70,7 +70,7 @@ void vapplogsiz(int prio, int size, const char* fmt, va_list args)
{
if (opt_debug || prio != LOG_DEBUG) {
if (use_syslog || opt_log_output || prio <= opt_log_level) {
char *tmp42 = (char *)calloc(size, 1);
char *tmp42 = (char *)calloc(size + 1, 1);
vsnprintf(tmp42, size, fmt, args);
_applog(prio, tmp42, false);
free(tmp42);

View File

@ -126,8 +126,9 @@ cl_program build_opencl_kernel(build_kernel_data *data, const char *filename)
applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
char *sz_log = (char *)malloc(log_size);
char *sz_log = (char *)malloc(log_size + 1);
status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL);
sz_log[log_size] = '\0';
applogsiz(LOG_ERR, log_size, "%s", sz_log);
free(sz_log);
goto out;