Fix stack smash bug in LOG_HEX() macro
Fixes issue 232
This commit is contained in:
parent
7e26869b68
commit
9935095a36
1 changed files with 4 additions and 3 deletions
|
@ -81,6 +81,7 @@ __attribute__((format(printf, 4, 5)))
|
||||||
/**
|
/**
|
||||||
* @macro LOG_HEX
|
* @macro LOG_HEX
|
||||||
* @brief Log a byte-array in hexadecimal format
|
* @brief Log a byte-array in hexadecimal format
|
||||||
|
* Max values: pcTag of 121 bytes + ": " + 300 bytes of data+ "\0" => acBuf of 1024 bytes
|
||||||
*/
|
*/
|
||||||
# ifdef LOG
|
# ifdef LOG
|
||||||
# define LOG_HEX(group, pcTag, pbtData, szBytes) do { \
|
# define LOG_HEX(group, pcTag, pbtData, szBytes) do { \
|
||||||
|
@ -95,9 +96,9 @@ __attribute__((format(printf, 4, 5)))
|
||||||
} \
|
} \
|
||||||
snprintf (__acBuf + __szBuf, sizeof(__acBuf) - __szBuf, "%s: ", pcTag); \
|
snprintf (__acBuf + __szBuf, sizeof(__acBuf) - __szBuf, "%s: ", pcTag); \
|
||||||
__szBuf += strlen (pcTag) + 2; \
|
__szBuf += strlen (pcTag) + 2; \
|
||||||
for (__szPos=0; __szPos < (size_t)(szBytes); __szPos++) { \
|
for (__szPos=0; (__szPos < (size_t)(szBytes)) && (__szBuf < sizeof(__acBuf)); __szPos++) { \
|
||||||
snprintf (__acBuf + __szBuf, sizeof(__acBuf) - __szBuf, "%02x ",((uint8_t *)(pbtData))[__szPos]); \
|
snprintf (__acBuf + __szBuf, sizeof(__acBuf) - __szBuf, "%02x ",((uint8_t *)(pbtData))[__szPos]); \
|
||||||
__szBuf += 4; \
|
__szBuf += 3; \
|
||||||
} \
|
} \
|
||||||
log_put (group, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", __acBuf); \
|
log_put (group, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", __acBuf); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue