mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-03-03 14:20:40 +01:00
monitor: RTNL IFLA flags were printed incorrectly
If flags was 0, then an uninitialized buffer was printed. Changed this so that if flags == 0, then just the value is printed. If flags != 0, then print flags values to a buffer that is big enough to hold all the sub-strings.
This commit is contained in:
parent
e69b21ccdf
commit
7a16f0a263
@ -2621,27 +2621,26 @@ static void ififlags_str(char *str, size_t size, uint16_t flags)
|
|||||||
{
|
{
|
||||||
int pos, i;
|
int pos, i;
|
||||||
|
|
||||||
if (!str || !flags)
|
pos = sprintf(str, "(0x%02x)", flags);
|
||||||
|
if (!flags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pos = sprintf(str, "(0x%02x)", flags);
|
|
||||||
pos += sprintf(str + pos, " [");
|
pos += sprintf(str + pos, " [");
|
||||||
|
|
||||||
for (i = 0; rtnl_flags[i].name; i++) {
|
for (i = 0; rtnl_flags[i].name; i++) {
|
||||||
if (flags & rtnl_flags[i].flag) {
|
if (flags & rtnl_flags[i].flag) {
|
||||||
flags &= ~rtnl_flags[i].flag;
|
flags &= ~rtnl_flags[i].flag;
|
||||||
pos += sprintf(str + pos, "%s%c", rtnl_flags[i].name,
|
pos += sprintf(str + pos, "%s%s", rtnl_flags[i].name,
|
||||||
flags ? ',' : ']');
|
flags ? "," : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags)
|
pos += sprintf(str + pos, "]");
|
||||||
pos += sprintf(str + pos, "0x%x]", flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_ifinfomsg(const struct ifinfomsg *info)
|
static void print_ifinfomsg(const struct ifinfomsg *info)
|
||||||
{
|
{
|
||||||
char str[64];
|
char str[256];
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user