From 426f22be0c8f4d2565f439dfd4d824ddfe65c9c9 Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr." Date: Wed, 15 May 2013 09:56:21 -0400 Subject: [PATCH] [Coverity] Copy into fixed size buffer (STRING_OVERFLOW) --- src/wimax/model/snr-to-block-error-rate-manager.cc | 3 +++ src/wimax/model/snr-to-block-error-rate-manager.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wimax/model/snr-to-block-error-rate-manager.cc b/src/wimax/model/snr-to-block-error-rate-manager.cc index 41ff60942..ec340211e 100644 --- a/src/wimax/model/snr-to-block-error-rate-manager.cc +++ b/src/wimax/model/snr-to-block-error-rate-manager.cc @@ -24,6 +24,7 @@ #include "ns3/snr-to-block-error-rate-record.h" #include "default-traces.h" #include "ns3/log.h" +#include "ns3/assert.h" #include NS_LOG_COMPONENT_DEFINE ("SNRToBlockErrorRateManager"); @@ -273,6 +274,8 @@ SNRToBlockErrorRateManager::ReLoadTraces (void) void SNRToBlockErrorRateManager::SetTraceFilePath (char *traceFilePath) { + NS_ASSERT_MSG (std::strlen (traceFilePath) < TRACE_FILE_PATH_SIZE, + "char * traceFilePath too long"); std::strcpy (m_traceFilePath, traceFilePath); } diff --git a/src/wimax/model/snr-to-block-error-rate-manager.h b/src/wimax/model/snr-to-block-error-rate-manager.h index e3e6915a5..8201a8be8 100644 --- a/src/wimax/model/snr-to-block-error-rate-manager.h +++ b/src/wimax/model/snr-to-block-error-rate-manager.h @@ -94,7 +94,8 @@ private: void ClearRecords (void); double m_speed; // in m/s uint8_t m_activateLoss; - char m_traceFilePath[1024]; + static const unsigned int TRACE_FILE_PATH_SIZE = 1024; + char m_traceFilePath[TRACE_FILE_PATH_SIZE]; std::vector * m_recordModulation[7];