Message ID | 20250512144921.27555-5-ivan.hu@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | lib: fwts_log: fix the potential overflow for dumping all log fields | expand |
diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c index 48240201..2cac0b04 100644 --- a/src/lib/src/fwts_log.c +++ b/src/lib/src/fwts_log.c @@ -204,7 +204,7 @@ void fwts_log_print_fields(void) fwts_log_field field; printf("Available fields: "); - for (field = 1; ; field <<= 1) { + for (field = 1; field <= LOG_NO_FIELDS; field <<= 1) { char *str = fwts_log_field_to_str(field); if (strcmp(str, LOG_UNKNOWN_FIELD) == 0) break;
Buglink: https://bugs.launchpad.net/fwts/+bug/2110180 Got coverity scan warning, CID 520641: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW) overflow_const: Expression field, overflows the type of field, which is type fwts_log_field. Simply add the for loop range for get rid of coverity scan warning. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> --- src/lib/src/fwts_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)