[nrf52840] check return value of vsnprintf in otPlatLog (#2691)

This commit is contained in:
Marco Studerus
2018-04-30 13:47:01 -07:00
committed by Jonathan Hui
parent 87a4e713d2
commit 273e6f9ba4
+4 -1
View File
@@ -145,6 +145,7 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
(void)aLogRegion;
uint16_t length = 0;
int charsWritten;
char logString[LOG_PARSE_BUFFER_SIZE + 1];
otEXPECT(sLogInitialized == true);
@@ -159,7 +160,9 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
// Parse user string.
va_list paramList;
va_start(paramList, aFormat);
length += vsnprintf(&logString[length], (LOG_PARSE_BUFFER_SIZE - length), aFormat, paramList);
charsWritten = vsnprintf(&logString[length], (LOG_PARSE_BUFFER_SIZE - length), aFormat, paramList);
otEXPECT(charsWritten >= 0);
length += charsWritten;
if (length > LOG_PARSE_BUFFER_SIZE)
{