From 94c8faab9f5b7dfcf11b6a0084cf54029badb125 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周日, 24 4月 2016 18:25:36 +0800 Subject: [PATCH] Fix tests for device dependent info, convert to strndup, fix out of bounds access --- libscpi/src/error.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libscpi/src/error.c b/libscpi/src/error.c index 8913ab8..3b9ca01 100644 --- a/libscpi/src/error.c +++ b/libscpi/src/error.c @@ -128,7 +128,7 @@ error_value.device_dependent_info = info; if (!fifo_add(&context->error_queue, &error_value)) { fifo_remove_last(&context->error_queue, &error_value); - // TODO free device_dependent_info + SCPIDEFINE_free(&context->error_info_heap, error_value.device_dependent_info, false); error_value.error_code = SCPI_ERROR_QUEUE_OVERFLOW; error_value.device_dependent_info = NULL; fifo_add(&context->error_queue, &error_value); @@ -162,13 +162,13 @@ * @param context - scpi context * @param err - error number */ -void SCPI_ErrorPushEx(scpi_t * context, int16_t err, char * info) { +void SCPI_ErrorPushEx(scpi_t * context, int16_t err, char * info, size_t info_len) { int i; char * info_ptr = NULL; #if USE_DEVICE_DEPENDENT_ERROR_INFORMATION if (info) { - info_ptr = SCPIDEFINE_strdup(&context->error_info_heap, info); + info_ptr = SCPIDEFINE_strndup(&context->error_info_heap, info, info_len); } #endif @@ -199,7 +199,7 @@ * @param err - error number */ void SCPI_ErrorPush(scpi_t * context, int16_t err) { - SCPI_ErrorPushEx(context, err, NULL); + SCPI_ErrorPushEx(context, err, NULL, 0); return; } -- Gitblit v1.9.1