[Mod] Fixed hexdump not escaping format specifiers
This commit is contained in:
parent
92cb09a932
commit
7209690bf6
1 changed files with 9 additions and 3 deletions
|
@ -471,7 +471,7 @@ uint32_t Module::reflect(uint32_t in, uint8_t bits) {
|
||||||
void Module::hexdump(const char* level, uint8_t* data, size_t len, uint32_t offset, uint8_t width, bool be) {
|
void Module::hexdump(const char* level, uint8_t* data, size_t len, uint32_t offset, uint8_t width, bool be) {
|
||||||
size_t rem_len = len;
|
size_t rem_len = len;
|
||||||
for(size_t i = 0; i < len; i+=16) {
|
for(size_t i = 0; i < len; i+=16) {
|
||||||
char str[80];
|
char str[120];
|
||||||
sprintf(str, "%07" PRIx32 " ", i+offset);
|
sprintf(str, "%07" PRIx32 " ", i+offset);
|
||||||
size_t line_len = 16;
|
size_t line_len = 16;
|
||||||
if(rem_len < line_len) {
|
if(rem_len < line_len) {
|
||||||
|
@ -497,15 +497,21 @@ void Module::hexdump(const char* level, uint8_t* data, size_t len, uint32_t offs
|
||||||
}
|
}
|
||||||
str[56] = '|';
|
str[56] = '|';
|
||||||
str[57] = ' ';
|
str[57] = ' ';
|
||||||
|
|
||||||
|
// at this point we need to start escaping "%" characters
|
||||||
|
char* strPtr = &str[58];
|
||||||
for(size_t j = 0; j < line_len; j++) {
|
for(size_t j = 0; j < line_len; j++) {
|
||||||
char c = data[i+j];
|
char c = data[i+j];
|
||||||
if((c < ' ') || (c > '~')) {
|
if((c < ' ') || (c > '~')) {
|
||||||
c = '.';
|
c = '.';
|
||||||
|
} else if(c == '%') {
|
||||||
|
*strPtr++ = '%';
|
||||||
}
|
}
|
||||||
sprintf(&str[58 + j], "%c", c);
|
sprintf(strPtr++, "%c", c);
|
||||||
|
|
||||||
}
|
}
|
||||||
for(size_t j = line_len; j < 16; j++) {
|
for(size_t j = line_len; j < 16; j++) {
|
||||||
sprintf(&str[58 + j], " ");
|
sprintf(strPtr++, " ");
|
||||||
}
|
}
|
||||||
if(level) {
|
if(level) {
|
||||||
RADIOLIB_DEBUG_PRINT(level);
|
RADIOLIB_DEBUG_PRINT(level);
|
||||||
|
|
Loading…
Add table
Reference in a new issue