aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-02-16 15:07:46 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-02-16 15:07:46 +0100
commita61064fcef13f38e304fc119aaa910871c38190b (patch)
tree303d9a38ed8c9efc3d448471e064242f0112732d
parent733f7a54f79d1e12a8745f0804c8394ed0136eb2 (diff)
cec-ctl: showTopology(): fix level wraparound bug
The unsigned level variable could wrap around if you have a weird situation where one device has physical address 4.0.0.0 and another 3.1.0.0. When this happens cec-ctl -S would start spewing a zillion tab characters. Ensure that level is never less than 1. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/cec-ctl/cec-ctl.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 72b80aa9..f6aa7c7d 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -698,7 +698,7 @@ static int showTopology(struct node *node)
memcpy(pas, phys_addrs, sizeof(pas));
std::sort(pas, pas + 16);
- unsigned level = 0;
+ int level = 0;
unsigned last_pa_mask = 0;
if ((pas[0] >> 8) == 0xffff)
@@ -723,7 +723,9 @@ static int showTopology(struct node *node)
level--;
}
printf("\t");
- for (unsigned j = 0; j < level; j++)
+ if (level < 1)
+ level = 1;
+ for (int j = 0; j < level; j++)
printf(" ");
printf("%x.%x.%x.%x: %s\n", cec_phys_addr_exp(pa),
cec_la2s(la));

Privacy Policy