mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[nrf52840] check return value of vsnprintf in otPlatLog (#2691)
This commit is contained in:
committed by
Jonathan Hui
parent
87a4e713d2
commit
273e6f9ba4
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user