]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
debug-generator: assert breakpoint type is valid before bit shift
authorLuca Boccassi <luca.boccassi@gmail.com>
Sat, 11 Apr 2026 21:50:39 +0000 (22:50 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 12 Apr 2026 12:25:28 +0000 (13:25 +0100)
The BreakpointType enum includes _BREAKPOINT_TYPE_INVALID (-EINVAL),
so Coverity flags the bit shift as potentially using a negative shift
amount. Add an assert to verify the type is in valid range, since the
static table only contains valid entries.

CID#1568482

Follow-up for 1929226e7e649b72f3f9acd464eaac771c00945c

src/debug-generator/debug-generator.c

index e3b7768fbc8cf36dbf27ba9a2bc649e88cd456ef..9ef271343cc596fd15afacd914cec0fcf5038b67 100644 (file)
@@ -101,6 +101,7 @@ static int parse_breakpoint_from_string(const char *s, uint32_t *ret_breakpoints
 
                 FOREACH_ELEMENT(i, breakpoint_info_table)
                         if (FLAGS_SET(i->validity, BREAKPOINT_DEFAULT) && breakpoint_applies(i, INT_MAX)) {
+                                assert(i->type >= 0 && i->type < _BREAKPOINT_TYPE_MAX); /* silence coverity */
                                 breakpoints |= UINT32_C(1) << i->type;
                                 found_default = true;
                                 break;