Skip to content
Snippets Groups Projects
Commit bb0d2496 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Don't append the stale static string in fmsgattr_str()

When this function was called multiple times (e.g. multiple messages in a pkt),
it would keep appending to the current (static) string, eventually overflowing
the buffer and corrupting the stack. Although reported in pktdump, it could
have also happened with fmsgdump if passed multiple stored message (.msg) files.

Fixes #295 reported by Nelgin
parent dcd8d8ee
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2437 passed
......@@ -32,6 +32,7 @@ const char* fmsgattr_str(uint16_t attr)
{
char str[64] = "";
str[0] = '\0';
#define FIDO_ATTR_CHECK(a, f) if(a&FIDO_##f) sprintf(str + strlen(str), "%s%s", str[0] == 0 ? "" : ", ", #f);
FIDO_ATTR_CHECK(attr, PRIVATE);
FIDO_ATTR_CHECK(attr, CRASH);
......
......@@ -52,6 +52,7 @@ const char* fmsgattr_str(uint16_t attr)
{
static char str[64] = "";
str[0] = '\0';
#define FIDO_ATTR_CHECK(a, f) if(a&FIDO_##f) sprintf(str + strlen(str), "%s%s", str[0] == 0 ? "" : ", ", #f);
FIDO_ATTR_CHECK(attr, PRIVATE);
FIDO_ATTR_CHECK(attr, CRASH);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment